diff options
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 238 |
1 files changed, 40 insertions, 198 deletions
@@ -1,218 +1,60 @@ { inputs = { - flake-utils.url = "github:numtide/flake-utils"; nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; - }; + unstable.url = "github:nixos/nixpkgs/nixos-unstable"; - outputs = { - self, - nixpkgs, - flake-utils, - }: let - mapOverlayOverride = namespace: overlay: final: prev: let - overlayPkgs = overlay final prev; - in - { - "${namespace}" = builtins.removeAttrs overlayPkgs ["override"]; - } - // (overlayPkgs.override or {}); - - doctrineNoPkgs = self.lib.mkDoctrine { - lib = nixpkgs.lib; - pkgs = null; + home-manager = { + url = "github:nix-community/home-manager/release-25.05"; + inputs.nixpkgs.follows = "nixpkgs"; }; - in - flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs {inherit system;}; - in { - formatter = pkgs.alejandra; - - packages = - (import nixpkgs { - inherit system; - overlays = [(mapOverlayOverride doctrineNoPkgs.prefix (import ./pkgs))]; - }).${ - doctrineNoPkgs.prefix - }; - }) - // { - templates = let - system-flake = { - path = ./templates/system-flake; - description = "Opinionated flake for a NixOS system with Home Manager"; - }; - in { - inherit system-flake; - - default = system-flake; - }; - - overlays = let - overlay = mapOverlayOverride doctrineNoPkgs.prefix (import ./pkgs); - in { - default = overlay; - ${doctrineNoPkgs.prefix} = overlay; - }; - - homeManagerModules.default = ./modules; - nixosModules.default = ./modules; - - lib = { - mkDoctrine = import ./doctrine; - - mkSystemFlake = { - flakes, - system, - doctrinePrefix ? null, - formatter ? "alejandra", - paths ? {}, - }: let - mkDoctrine = args: - self.lib.mkDoctrine - (args - // optionalAttrs (doctrinePrefix != null) { - prefix = doctrinePrefix; - }); - - doctrineNoPkgs = mkDoctrine { - lib = nixpkgs.lib; - pkgs = null; - }; - - optionalFlake = name: - if flakes ? "${name}" - then flakes.${name} - else null; - requireFlake = name: - if flakes ? "${name}" - then flakes.${name} - else throw "Required flake input '${name}' is missing"; + nur.url = "github:nix-community/NUR"; + impermanence.url = "github:nix-community/impermanence"; + hm-isolation.url = "github:3442/hm-isolation"; - nur = optionalFlake "nur"; - nixpkgs = requireFlake "nixpkgs"; - unstable = optionalFlake "unstable"; - - home-manager = - if hmSourcePath != null - then requireFlake "home-manager" - else null; - - pathFromSelf = path: builtins.toPath "${flakes.self}" + "/${path}"; - - localOverlayPath = pathFromSelf paths.localOverlay; - nixpkgsConfigPath = pathFromSelf paths.nixpkgsConfig; - nixosSourcePath = pathFromSelf paths.nixosSource; - nixosPlatformsPath = pathFromSelf paths.nixosPlatforms; - hmSourcePath = pathFromSelf paths.hmSource; - hmPlatformsPath = pathFromSelf paths.hmPlatforms; - - pkgs = importPkgs nixpkgs; - - importPkgs = flake: - import flake ({ - inherit system; + nixvirt = { + url = "github:AshleyYakeley/NixVirt"; + inputs.nixpkgs.follows = "nixpkgs"; + }; - overlays = let - conditions = [ - { - overlay = nur.overlays.default; - condition = nur != null; - } - # NB: Preserve the relative order - { - overlay = self.overlays.default; - condition = true; - } - { - overlay = flakes.self.overlays.default; - condition = true; - } - ]; - in - builtins.map (cond: cond.overlay) (builtins.filter (cond: cond.condition) conditions); - } - // optionalAttrs (paths ? nixpkgsConfig) { - config = import nixpkgsConfigPath {inherit (nixpkgs) lib;}; - }); + flake-utils.url = "github:numtide/flake-utils"; - inherit (pkgs) lib; - inherit (nixpkgs.lib) optionalAttrs; # Prevents infinite recursion - inherit (doctrineNoPkgs) prefix; - inherit (doctrineNoPkgs.lib) importAll; - in - { - formatter.${system} = - if formatter == "alejandra" - then pkgs.alejandra - else if formatter == "nixpkgs-fmt" - then pkgs.nixpkgs-fmt - else throw "Unknown formatter: '${formatter}'"; + lanzaboote = { + url = "github:nix-community/lanzaboote"; - packages.${system} = pkgs.${prefix}; + inputs = { + nixpkgs.follows = "nixpkgs"; + pre-commit-hooks-nix.follows = ""; + }; + }; - overlays.default = final: prev: let - overlay = final: prev: - if paths ? localOverlay - then import localOverlayPath {inherit final prev flakes;} - else {}; - in - mapOverlayOverride prefix overlay final prev - // optionalAttrs (unstable != null) { - unstable = importPkgs unstable; - }; - } - // optionalAttrs (paths ? nixosSource) { - nixosConfigurations = let - nixosSystem = {modules}: - lib.makeOverridable nixpkgs.lib.nixosSystem { - inherit modules pkgs system; + trivionomicon = { + url = "./trivionomicon"; + inputs = { + flake-utils.follows = "flake-utils"; + nixpkgs.follows = "nixpkgs"; + }; + }; - specialArgs = { - inherit flakes; + vpsadminos.url = "github:vpsfreecz/vpsadminos"; + }; - doctrine = mkDoctrine { - inherit pkgs; - namespace = "sys"; - }; - }; - }; + outputs = flakes: + flakes.trivionomicon.lib.mkSystemFlake { + inherit flakes; - hostConfig = platform: - nixosSystem { - modules = [ - self.nixosModules.default - nixosSourcePath - platform - ]; - }; - in - lib.mapAttrs (_: hostConfig) (importAll {root = nixosPlatformsPath;}); - } - // optionalAttrs (paths ? hmSource) { - homeConfigurations = let - home = name: platform: - home-manager.lib.homeManagerConfiguration { - inherit pkgs; + system = "x86_64-linux"; + doctrinePrefix = "local"; - extraSpecialArgs = { - inherit flakes; + paths = { + localOverlay = "pkgs"; + nixpkgsConfig = "pkgs/config"; - doctrine = mkDoctrine { - inherit pkgs; - namespace = "hm"; - }; - }; + nixosSource = "sys"; + nixosPlatforms = "sys/platform"; - modules = [ - self.homeManagerModules.default - hmSourcePath - platform - ]; - }; - in - lib.mapAttrs home (importAll {root = hmPlatformsPath;}); - }; + hmSource = "home"; + hmPlatforms = "home/platform"; }; }; } |
