{ description = "NixOS Machine Configurations by manuth"; inputs = { nixpkgs.url = "nixpkgs/f7207adcc68d9cafa29e3cd252a18743ae512c6a"; flake-utils.url = "github:numtide/flake-utils?ref=b1d9ab70662946ef0850d488da1c9019f3a9752a"; nixos-hardware.url = "github:NixOS/nixos-hardware?ref=d9e0b26202fd500cf3e79f73653cce7f7d541191"; home-manager = { url = "github:nix-community/home-manager?ref=892f76bd0aa09a0f7f73eb41834b8a904b6d0fad"; inputs.nixpkgs.follows = "nixpkgs"; }; sops-nix.url = "github:Mic92/sops-nix?ref=c279dec105dd53df13a5e57525da97905cc0f0d6"; minegrub-theme = { url = "github:Lxtharia/minegrub-theme?ref=08fe7f2b07e0f39426d53e1a1ab5b071e77b9e39"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, flake-utils, nixos-hardware, home-manager, sops-nix, minegrub-theme }: ( let inherit (nixpkgs) lib; defaultMachine = { system = "x86_64-linux"; modules = [ ]; config = { pkgs, ... }: { dualBoot = false; school = false; timeZone = "Europe/Zurich"; keyMap = "de_CH-latin1"; keyboardLayout = "ch"; localeSettings = let defaultLocale = "en_US.UTF-8"; in { LANG = "de_CH.UTF-8"; LANGUAGE = defaultLocale; LC_MESSAGE = defaultLocale; }; nvidia = true; xone = true; users = { manuel = { fullName = "Manuel Thalmann"; mail = "m@nuth.ch"; sudoer = true; defaultShell = pkgs.fish; }; }; }; }; machineDefinitions = { nixos.config = { ... }: { }; manu-surface.config = { ... }: { school = true; modules = [ nixos-hardware.nixosModules.microsoft-surface-pro-intel ]; }; }; machines = builtins.mapAttrs ( name: machineDefinition: defaultMachine // machineDefinition // { config = { callPackage, ... }: ((callPackage defaultMachine.config { }) // (callPackage machineDefinition.config { })); }) machineDefinitions; tryFiles = import ./lib/utils/try-files.nix { inherit lib; }; packageDefinitions = { aliae = import ./lib/packages/aliae.nix; ttf-ms-win11 = import ./lib/packages/ttf-ms-win11.nix; xone = import ./lib/packages/xone.nix; }; in flake-utils.lib.eachDefaultSystem ( system: let pkgs = import nixpkgs { inherit system; config = {}; overlays = [ sops-nix.overlays.default ]; }; in { packages = (builtins.mapAttrs (name: packageDefinition: pkgs.callPackage packageDefinition { }) packageDefinitions) // { rcloneDocs = let module = lib.evalModules { modules = [ ({ pkgs, ... }@args: { inherit (import ./lib/modules/rclone.nix args) options; }) ]; }; optionsDoc = pkgs.nixosOptionsDoc { options = module.options; }; in pkgs.runCommand "options-doc.md" {} '' cat ${optionsDoc.optionsCommonMark} >> $out ''; }; devShells.default = pkgs.mkShellNoCC ( with pkgs; { sopsPGPKeyDirs = [ "${toString ./.}/secrets/keys/hosts" "${toString ./.}/secrets/keys/users" ]; packages = [ mkpasswd nixos-rebuild sops sops-import-keys-hook ssh-to-age ssh-to-pgp ]; nativeBuildInputs = [ sops-import-keys-hook ]; }); } ) // { overlays.default = final: prev: ( lib.attrsets.concatMapAttrs ( name: packageDefinition: let package = final.callPackage packageDefinition { }; in if name == "xone" then { linuxPackages_latest.xone = package; } else { ${name} = package; }) packageDefinitions); nixosConfigurations = builtins.mapAttrs ( hostname: { system, config, modules }@machine: nixpkgs.lib.nixosSystem { inherit system; modules = [ ( { pkgs, ... }: { config = { _module.args = { machine = machine // { name = hostname; config = (pkgs.callPackage config { }); }; }; nixpkgs.overlays = [ self.overlays.default ]; home-manager.sharedModules = [ sops-nix.homeManagerModules.sops ]; }; }) home-manager.nixosModules.home-manager minegrub-theme.nixosModules.default sops-nix.nixosModules.sops ./lib/configuration.nix (tryFiles [ ./lib/machines/${hostname}.nix ] ./lib/hardware/base.nix) ] ++ modules; }) machines; homeConfigurations = let lib = nixpkgs.lib; in lib.attrsets.concatMapAttrs ( hostname: machine: let pkgs = import nixpkgs { inherit (machine) system; }; machineConfig = pkgs.callPackage machine.config { }; in lib.attrsets.concatMapAttrs ( username: user: { "${username}@${hostname}" = home-manager.lib.homeManagerConfiguration { modules = let getUserModule = pkgs.callPackage (import ./lib/utils/user-module.nix); in getUserModule { machine = machine // { name = hostname; config = machineConfig; }; user = { name = username; } // user; } ++ [ sops-nix.homeManagerModules.sops ]; }; }) machineConfig.users) machines; }); }