Compare commits

...

2 commits

Author SHA1 Message Date
7486f2409b formatting? 2024-06-28 07:55:01 -07:00
608982d8f2 more rework 2024-06-28 07:52:41 -07:00
2 changed files with 56 additions and 20 deletions

View file

@ -17,29 +17,49 @@
}; };
}; };
outputs = { self, nixpkgs, ... }@inputs: outputs =
{ self, nixpkgs, ... }@inputs:
{ {
nixosConfigurations = nixosConfigurations =
let let
cleanHostname = config: builtins.removeAttrs config [ "hostname" ]; lib = import ./lib { inherit (nixpkgs) lib; };
toNixosConfigPart = config: { name = config.hostname; value = nixpkgs.lib.nixosSystem (cleanHostname config); };
cleanHostname =
config:
builtins.removeAttrs config [ "hostname" ];
toPartialNixosConfigSet =
config:
{
name = config.hostname;
value = nixpkgs.lib.nixosSystem (cleanHostname config);
};
toNixosSystemConfig =
{ hostname, system }:
{
inherit system hostname;
specialArgs = { inherit inputs; };
modules = [
./hosts/${hostname}/hardware-configuration.nix
./hosts/${hostname}/configuration.nix
inputs.home-manager.nixosModules.default
];
};
compileSystems = systems: lib.right builtins.listToAttrs (map toPartialNixosConfigSet) (map toNixosSystemConfig) systems;
in in
builtins.listToAttrs compileSystems
(map toNixosConfigPart [
(map {
({ hostname, system }: { hostname = "snowhawk";
inherit system hostname; system = "x86_64-linux";
specialArgs = { inherit inputs; }; }
modules = [ {
./hosts/${hostname}/hardware-configuration.nix hostname = "sprite";
./hosts/${hostname}/configuration.nix system = "aarch64-linux";
inputs.home-manager.nixosModules.default }
]; {
}) hostname = "nixos";
[ system = "x86_64-linux";
{ hostname = "snowhawk"; system = "x86_64-linux"; } }
{ hostname = "sprite"; system = "aarch64-linux"; } ];
{ hostname = "nixos"; system = "x86_64-linux"; }
]));
}; };
} }

16
lib/default.nix Normal file
View 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));
}