Refactoring of the machines

This commit is contained in:
Julien Malka 2022-02-19 22:05:59 +01:00
parent 4841bdf10f
commit b9f3d8f46c
No known key found for this signature in database
GPG key ID: 3C68E13964FEA07F
5 changed files with 97 additions and 11 deletions

39
flake.lock generated
View file

@ -16,6 +16,27 @@
"type": "gitlab"
}
},
"dns": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1635273082,
"narHash": "sha256-EHiDP2jEa7Ai5ZwIf5uld9RVFcV77+2SUxjQXwJsJa0=",
"owner": "kirelagin",
"repo": "dns.nix",
"rev": "c7b9645da9c0ddce4f9de4ef27ec01bb8108039a",
"type": "github"
},
"original": {
"owner": "kirelagin",
"repo": "dns.nix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@ -33,6 +54,21 @@
}
},
"flake-utils": {
"locked": {
"lastModified": 1614513358,
"narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5466c5bbece17adaab2d82fae80b46e807611bf3",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1629481132,
"narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=",
@ -85,7 +121,7 @@
},
"neovim-flake": {
"inputs": {
"flake-utils": "flake-utils",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs"
},
"locked": {
@ -204,6 +240,7 @@
},
"root": {
"inputs": {
"dns": "dns",
"home-manager": "home-manager",
"homepage": "homepage",
"neovim-nightly-overlay": "neovim-nightly-overlay",

View file

@ -8,6 +8,11 @@
inputs.nixpkgs.follows = "nixpkgs";
};
dns = {
url = "github:kirelagin/dns.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
neovim-nightly-overlay = {
url = "github:nix-community/neovim-nightly-overlay";
inputs.nixpkgs.follows = "unstable";
@ -36,7 +41,7 @@
outputs = { self, home-manager, nixpkgs, unstable, sops-nix, neovim-nightly-overlay, nur, ... }@inputs:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
pkgsrpi = import nixpkgs { system = "aarch64-linux";};
pkgsrpi = import nixpkgs { system = "aarch64-linux"; };
lib = nixpkgs.lib.extend (import ./lib inputs);
in
with lib;
@ -48,19 +53,18 @@
})
(builtins.attrNames (builtins.readDir ./modules)));
nixosConfigurations = builtins.mapAttrs (name: value: (mkMachine {host=name; host-config=value; modules=self.nixosModules;})) (importConfig ./machines) //
{"lambda" = mkMachine { host = "lambda"; host-config = import ./rpi.nix; modules=self.nixosModules; system="aarch64-linux";};};
nixosConfigurations = builtins.mapAttrs (name: value: (mkMachine { host = name; host-config = value; modules = self.nixosModules; system = luj.machines.${name}.arch; })) (importConfig ./machines);
packages."x86_64-linux" = {
tinystatus = import ./packages/tinystatus { inherit pkgs; };
mosh = pkgs.callPackage ./packages/mosh {};
flaresolverr = pkgs.callPackage ./packages/flaresolverr {};
htpdate = pkgs.callPackage ./packages/htpdate {};
mosh = pkgs.callPackage ./packages/mosh { };
flaresolverr = pkgs.callPackage ./packages/flaresolverr { };
htpdate = pkgs.callPackage ./packages/htpdate { };
};
packages."aarch64-linux" = {
tinystatus = import ./packages/tinystatus { pkgs = pkgsrpi; };
mosh = pkgsrpi.callPackage ./packages/mosh {};
flaresolverr = pkgsrpi.callPackage ./packages/flaresolverr {};
htpdate = pkgsrpi.callPackage ./packages/htpdate {};
mosh = pkgsrpi.callPackage ./packages/mosh { };
flaresolverr = pkgsrpi.callPackage ./packages/flaresolverr { };
htpdate = pkgsrpi.callPackage ./packages/htpdate { };
};
};
}

View file

@ -52,5 +52,7 @@ in
};
};
luj = import ./luj.nix final;
}

43
lib/luj.nix Normal file
View file

@ -0,0 +1,43 @@
lib: with lib; let
modules = [
{
options.machines = mkOption {
description = "My machines";
type = with types; attrsOf (submodule ({ name, ... }: {
freeformType = attrs;
options = {
hostname = mkOption {
description = "The machine's hostname";
type = str;
default = name;
readOnly = true;
};
};
}));
default = {};
};
config = {
_module.freeformType = with types; attrs;
domain = "julienmalka.me";
machines = {
lisa = {
arch = "x86_64-linux";
};
newton = {
arch = "x86_64-linux";
};
macintosh = {
arch = "x86_64-linux";
};
lambda = {
arch = "aarch64-linux";
};
};
};
}
];
in (evalModules { inherit modules; }).config

View file

@ -2,7 +2,7 @@
{
imports = [ ./users/status.nix ];
imports = [ ../../users/status.nix ];
# NixOS wants to enable GRUB by default
boot.loader.grub.enable = false;