1
0

Unclutter flake

This commit is contained in:
clerie 2023-03-23 16:45:30 +01:00
parent 931fe57cf2
commit d30cbbf99d
2 changed files with 55 additions and 44 deletions

View File

@ -10,40 +10,12 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = { self, nixpkgs, nixos-exporter, solid-xmpp-alarm, ... }: let outputs = { self, nixpkgs, nixos-exporter, solid-xmpp-alarm, ... }@inputs: let
pkgs = import nixpkgs { helper = (import ./lib/flake-helper.nix) inputs;
overlays = [
(import ./pkgs/overlay.nix)
];
system = "x86_64-linux";
};
system = "x86_64-linux";
in { in {
nixosConfigurations = let nixosConfigurations = let
generateNixosSystem = name: nixpkgs.lib.nixosSystem { inherit (helper)
system = "x86_64-linux"; generateNixosSystem;
modules = [
({ ... }: {
/*
Make the contents of the flake availiable to modules.
Useful for having the monitoring server scraping the
target config from all other servers automatically.
*/
_module.args._nixfiles = self;
})
./configuration/common
({ ... }: {
nixpkgs.overlays = [
(_: _: {
inherit (nixos-exporter.packages.${system})
nixos-exporter;
})
];
})
solid-xmpp-alarm.nixosModules.solid-xmpp-alarm
(./hosts + "/${name}/configuration.nix")
];
};
in { in {
aluminium = generateNixosSystem "aluminium"; aluminium = generateNixosSystem "aluminium";
backup-4 = generateNixosSystem "backup-4"; backup-4 = generateNixosSystem "backup-4";
@ -74,19 +46,16 @@
meta = { meta = {
nixpkgs = import nixpkgs {}; nixpkgs = import nixpkgs {};
}; };
} // helper.mapToColmenaHosts self.nixosConfigurations;
defaults = { name, ... }: { packages.x86_64-linux = let
deployment = { pkgs = import nixpkgs {
targetHost = "${name}.net.clerie.de"; overlays = [
targetUser = null; (import ./pkgs/overlay.nix)
];
system = "x86_64-linux";
}; };
}; in {
} // builtins.mapAttrs (name: host: {
nixpkgs.system = host.config.nixpkgs.system;
imports = host._module.args.modules;
deployment.allowLocalDeployment = builtins.any (n: n == name) [ "schule" "osmium" ];
}) self.nixosConfigurations;
packages.x86_64-linux = {
inherit (pkgs) inherit (pkgs)
anycast_healthchecker anycast_healthchecker
flask-excel flask-excel
@ -100,7 +69,7 @@
hydraJobs = { hydraJobs = {
inherit (self) inherit (self)
packages; packages;
nixosConfigurations = builtins.mapAttrs (name: host: host.config.system.build.toplevel) self.nixosConfigurations; nixosConfigurations = helper.buildHosts self.nixosConfigurations;
iso = self.nixosConfigurations._iso.config.system.build.isoImage; iso = self.nixosConfigurations._iso.config.system.build.isoImage;
}; };
}; };

42
lib/flake-helper.nix Normal file
View File

@ -0,0 +1,42 @@
{ self, nixpkgs, nixos-exporter, solid-xmpp-alarm, ... }@inputs:
rec {
generateNixosSystem = name: nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ ... }: {
/*
Make the contents of the flake availiable to modules.
Useful for having the monitoring server scraping the
target config from all other servers automatically.
*/
_module.args._nixfiles = self;
})
../configuration/common
({ ... }: {
nixpkgs.overlays = [
(_: _: {
inherit (nixos-exporter.packages."x86_64-linux")
nixos-exporter;
})
];
})
solid-xmpp-alarm.nixosModules.solid-xmpp-alarm
(../hosts + "/${name}/configuration.nix")
];
};
generateColmenaHost = name: hostSystem: {
deployment = {
targetHost = "${name}.net.clerie.de";
targetUser = null;
};
nixpkgs.system = hostSystem.config.nixpkgs.system;
imports = hostSystem._module.args.modules;
deployment.allowLocalDeployment = builtins.any (n: n == name) [ "schule" "osmium" ];
};
mapToColmenaHosts = hosts: builtins.mapAttrs (generateColmenaHost) hosts;
buildHosts = hosts: builtins.mapAttrs (name: host: host.config.system.build.toplevel) hosts;
}