Skip to content

Instantly share code, notes, and snippets.

@qbit
Created April 30, 2022 14:08
Show Gist options
  • Save qbit/e4d3f8bb3e4ca716ef7789ed23454b55 to your computer and use it in GitHub Desktop.
Save qbit/e4d3f8bb3e4ca716ef7789ed23454b55 to your computer and use it in GitHub Desktop.
{
description = "bold.daemon";
# TODO: figure out how to make things pure (./pkgs...)
inputs = {
unstable = { url = "github:NixOS/nixpkgs/nixos-unstable"; };
stable = { url = "github:NixOS/nixpkgs/nixos-21.11"; };
};
outputs = { self, unstable, stable }:
let
# use pkgs from unstable
pkgs = (import unstable) { system = "x86_64-linux"; };
#pkgs = (import unstable);
hosts = (pkgs.lib.attrNames
(pkgs.lib.filterAttrs (_: entryType: entryType == "directory")
(builtins.readDir ./hosts)));
build-sys = hostSet:
(let
parts = pkgs.lib.splitString "." hostSet;
myName = builtins.elemAt parts 0;
mySys = builtins.elemAt parts 1;
myPkg = builtins.elemAt parts 2;
hostSys = {
system = mySys;
modules = [
(import (./default.nix))
(import (./hosts + "/${myName}/configuration.nix"))
(import (./hosts + "/${myName}/hardware-configuration.nix"))
];
};
in {
name = myName;
value = if myPkg == "unstable" then
unstable.lib.nixosSystem hostSys
else
stable.lib.nixosSystem hostSys;
});
in {
nixosConfigurations =
builtins.listToAttrs (map (host: [ (build-sys host) ]) hosts);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment