Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

flake: clean up flake module and add nixos/home-manager

+121 -62
+1 -2
flake.nix
··· 17 17 { 18 18 imports = [ 19 19 ./nix/lib.nix 20 - ./nix/flake/module.nix 21 - ./nix/legacy-flake-module.nix 20 + ./nix/flake/part.nix 22 21 inputs.process-compose-flake.flakeModule 23 22 ]; 24 23
-35
nix/flake/module.nix
··· 1 - { config, lib, ... }: 2 - { 3 - imports = [ 4 - ./sower.nix 5 - ./sowerjobs.nix 6 - ]; 7 - 8 - perSystem = 9 - { 10 - self', 11 - ... 12 - }: 13 - let 14 - cfg = config.sower.jobs; 15 - is_service = builtins.hasAttr "sowerServices"; 16 - 17 - checks = lib.mapAttrs' (n: v: lib.nameValuePair "check/${n}" v) self'.checks; 18 - packages = lib.pipe self'.packages [ 19 - (lib.filterAttrs (_: v: !(is_service v))) 20 - (lib.mapAttrs' (n: v: lib.nameValuePair "package/${n}" v)) 21 - ]; 22 - services = lib.pipe self'.packages [ 23 - (lib.filterAttrs (_: v: (is_service v))) 24 - (lib.mapAttrs' (n: v: lib.nameValuePair "package/${n}" v)) 25 - ]; 26 - in 27 - { 28 - 29 - sowerJobs = lib.mkMerge [ 30 - (lib.mkIf cfg.checks.enable checks) 31 - (lib.mkIf cfg.packages.enable packages) 32 - (lib.mkIf cfg.services.enable services) 33 - ]; 34 - }; 35 - }
+120
nix/flake/part.nix
··· 1 + { 2 + config, 3 + inputs, 4 + lib, 5 + self, 6 + ... 7 + }: 8 + { 9 + imports = [ 10 + ./sowerjobs.nix 11 + ]; 12 + 13 + options = { 14 + sower = { 15 + enable = lib.mkOption { 16 + type = lib.types.bool; 17 + description = "enable sower features"; 18 + default = true; 19 + }; 20 + 21 + jobs = { 22 + checks.enable = lib.mkEnableOption "building checks"; 23 + home-manager.enable = lib.mkEnableOption "building home-manager configurations"; 24 + nixos.enable = lib.mkEnableOption "building nixos configurations"; 25 + packages.enable = lib.mkEnableOption "building packages without services"; 26 + services.enable = lib.mkEnableOption "building packages with services"; 27 + }; 28 + }; 29 + }; 30 + 31 + config = { 32 + flake.nixosConfigurations = { 33 + example = inputs.nixpkgs.lib.nixosSystem { 34 + system = "x86_64-linux"; 35 + modules = [ 36 + "${inputs.nixpkgs}/nixos/maintainers/scripts/incus/incus-container-image.nix" 37 + { system.stateVersion = "25.11"; } 38 + ]; 39 + }; 40 + 41 + example-aarch64 = inputs.nixpkgs.lib.nixosSystem { 42 + system = "aarch64-linux"; 43 + modules = [ 44 + "${inputs.nixpkgs}/nixos/maintainers/scripts/incus/incus-container-image.nix" 45 + { system.stateVersion = "25.11"; } 46 + ]; 47 + }; 48 + }; 49 + 50 + sower.jobs = { 51 + home-manager.enable = lib.mkDefault true; 52 + nixos.enable = lib.mkDefault true; 53 + packages.enable = lib.mkDefault true; 54 + services.enable = lib.mkDefault true; 55 + }; 56 + 57 + perSystem = 58 + { 59 + self', 60 + system, 61 + ... 62 + }: 63 + let 64 + cfg = config.sower.jobs; 65 + is_service = builtins.hasAttr "sowerServices"; 66 + 67 + checks = lib.mapAttrs' (n: v: lib.nameValuePair "check/${n}" v) self'.checks; 68 + nixos = lib.pipe self.nixosConfigurations [ 69 + (lib.filterAttrs (_: nixosConfig: nixosConfig.pkgs.stdenv.hostPlatform.system == system)) 70 + (lib.mapAttrs' ( 71 + name: nixosConfig: 72 + lib.nameValuePair "nixos/${name}" ( 73 + nixosConfig.config.system.build.toplevel.overrideAttrs (old: { 74 + meta = (old.meta or { }) // { 75 + sower = { 76 + inherit name; 77 + seed_type = "nixos"; 78 + }; 79 + }; 80 + }) 81 + ) 82 + )) 83 + ]; 84 + home-manager = lib.pipe (self.homeConfigurations or { }) [ 85 + (lib.filterAttrs (_: homeConfig: homeConfig.pkgs.stdenv.hostPlatform.system == system)) 86 + (lib.mapAttrs' ( 87 + name: homeConfig: 88 + lib.nameValuePair "nixos/${name}" ( 89 + homeConfig.activationPackage.overrideAttrs (old: { 90 + meta = (old.meta or { }) // { 91 + sower = { 92 + inherit name; 93 + seed_type = "home-manager"; 94 + }; 95 + }; 96 + }) 97 + ) 98 + )) 99 + ]; 100 + packages = lib.pipe self'.packages [ 101 + (lib.filterAttrs (_: v: !(is_service v))) 102 + (lib.mapAttrs' (n: v: lib.nameValuePair "package/${n}" v)) 103 + ]; 104 + services = lib.pipe self'.packages [ 105 + (lib.filterAttrs (_: v: (is_service v))) 106 + (lib.mapAttrs' (n: v: lib.nameValuePair "package/${n}" v)) 107 + ]; 108 + in 109 + { 110 + 111 + sowerJobs = lib.mkMerge [ 112 + (lib.mkIf cfg.checks.enable checks) 113 + (lib.mkIf cfg.home-manager.enable home-manager) 114 + (lib.mkIf cfg.nixos.enable nixos) 115 + (lib.mkIf cfg.packages.enable packages) 116 + (lib.mkIf cfg.services.enable services) 117 + ]; 118 + }; 119 + }; 120 + }
-25
nix/flake/sower.nix
··· 1 - { lib, ... }: 2 - { 3 - options = { 4 - sower = { 5 - enable = lib.mkOption { 6 - type = lib.types.bool; 7 - description = "enable sower features"; 8 - default = true; 9 - }; 10 - 11 - jobs = { 12 - checks.enable = lib.mkEnableOption "building checks"; 13 - packages.enable = lib.mkEnableOption "building packages without services"; 14 - services.enable = lib.mkEnableOption "building packages with services"; 15 - }; 16 - }; 17 - }; 18 - 19 - config = { 20 - sower.jobs = { 21 - packages.enable = lib.mkDefault true; 22 - services.enable = lib.mkDefault true; 23 - }; 24 - }; 25 - }