more rework
This commit is contained in:
parent
4213303810
commit
608982d8f2
2 changed files with 46 additions and 19 deletions
35
flake.nix
35
flake.nix
|
@ -17,17 +17,16 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, ... }@inputs:
|
outputs =
|
||||||
|
{ self, nixpkgs, ... }@inputs:
|
||||||
{
|
{
|
||||||
nixosConfigurations =
|
nixosConfigurations =
|
||||||
let
|
let
|
||||||
|
lib = import ./lib { inherit (nixpkgs) lib; };
|
||||||
|
|
||||||
cleanHostname = config: builtins.removeAttrs config [ "hostname" ];
|
cleanHostname = config: builtins.removeAttrs config [ "hostname" ];
|
||||||
toNixosConfigPart = config: { name = config.hostname; value = nixpkgs.lib.nixosSystem (cleanHostname config); };
|
toPartialNixosConfigSet = config: { name = config.hostname; value = nixpkgs.lib.nixosSystem (cleanHostname config); };
|
||||||
in
|
toNixosSystemConfig = { hostname, system }: {
|
||||||
builtins.listToAttrs
|
|
||||||
(map toNixosConfigPart
|
|
||||||
(map
|
|
||||||
({ hostname, system }: {
|
|
||||||
inherit system hostname;
|
inherit system hostname;
|
||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
modules = [
|
modules = [
|
||||||
|
@ -35,11 +34,23 @@
|
||||||
./hosts/${hostname}/configuration.nix
|
./hosts/${hostname}/configuration.nix
|
||||||
inputs.home-manager.nixosModules.default
|
inputs.home-manager.nixosModules.default
|
||||||
];
|
];
|
||||||
})
|
};
|
||||||
|
compileSystems = systems: lib.right builtins.listToAttrs (map toPartialNixosConfigSet) (map toNixosSystemConfig) systems;
|
||||||
|
in
|
||||||
|
compileSystems
|
||||||
[
|
[
|
||||||
{ hostname = "snowhawk"; system = "x86_64-linux"; }
|
{
|
||||||
{ hostname = "sprite"; system = "aarch64-linux"; }
|
hostname = "snowhawk";
|
||||||
{ hostname = "nixos"; system = "x86_64-linux"; }
|
system = "x86_64-linux";
|
||||||
]));
|
}
|
||||||
|
{
|
||||||
|
hostname = "sprite";
|
||||||
|
system = "aarch64-linux";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
hostname = "nixos";
|
||||||
|
system = "x86_64-linux";
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
16
lib/default.nix
Normal file
16
lib/default.nix
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
with lib;
|
||||||
|
rec {
|
||||||
|
# Ternary operator
|
||||||
|
# Exaample:
|
||||||
|
# tern false 1 2 => 2
|
||||||
|
# tern true 1 2 => 1
|
||||||
|
tern = pred: x: y: if pred then x else y;
|
||||||
|
|
||||||
|
# Right-associate and chain following single-operand functions
|
||||||
|
# Example:
|
||||||
|
# right f g h 1 => f(g(h(1)))
|
||||||
|
right = f: g: tern (isFunction g)
|
||||||
|
(right (x: f (g (x))))
|
||||||
|
(f (g));
|
||||||
|
}
|
Loading…
Reference in a new issue