Personal Nix flake
nixos home-manager nix
1
fork

Configure Feed

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

refactor: Also use lib.packagesFromDirectoryRecursive for legacyPackages

+95 -104
+69 -74
nix/legacyPackages/ciMatrix.nix
··· 1 - {inputs, ...}: let 2 - inherit (inputs) self; 3 - inherit (self) systems; 4 - in { 5 - perSystem = { 6 - lib, 7 - pkgs, 8 - ... 9 - }: let 10 - getOutputInfo = mkDerivationPath: output: 11 - lib.mapAttrsToList (name: drv: { 12 - inherit name; 13 - derivation = 14 - name 15 - |> lib.strings.escapeNixIdentifier 16 - |> mkDerivationPath 17 - |> lib.escapeShellArg; 18 - system = drv.system or drv.pkgs.stdenv.hostPlatform.system; 19 - branch = drv.config.my.ci.branches or []; 20 - }) 21 - output; 22 - getPerSystemOutputInfo = mkDerivationPath: output: 23 - lib.concatMap (system: getOutputInfo (mkDerivationPath system) output.${system}) 24 - systems; 25 - filterToBuild = lib.filterAttrs (_: drv: drv.config.my.ci.build or false); 26 - filterPerSystemToBuild = lib.filterAttrsRecursive ( 27 - name: drv: 28 - !(lib.isDerivation drv) 29 - || ( 30 - (name != "default") 31 - && ( 32 - ((drv.passthru.my.ci.build or false) == true) 33 - || (builtins.elem drv.system (drv.passthru.my.ci.buildFor or [])) 34 - ) 1 + { 2 + inputs, 3 + lib, 4 + writeText, 5 + ... 6 + }: let 7 + inherit (inputs.self) devShells homeConfigurations nixosConfigurations packages systems; 8 + getOutputInfo = mkDerivationPath: output: 9 + lib.mapAttrsToList (name: drv: { 10 + inherit name; 11 + derivation = 12 + name 13 + |> lib.strings.escapeNixIdentifier 14 + |> mkDerivationPath 15 + |> lib.escapeShellArg; 16 + system = drv.system or drv.pkgs.stdenv.hostPlatform.system; 17 + branch = drv.config.my.ci.branches or []; 18 + }) 19 + output; 20 + getPerSystemOutputInfo = mkDerivationPath: output: 21 + lib.concatMap (system: getOutputInfo (mkDerivationPath system) output.${system}) 22 + systems; 23 + filterToBuild = lib.filterAttrs (_: drv: drv.config.my.ci.build or false); 24 + filterPerSystemToBuild = lib.filterAttrsRecursive ( 25 + name: drv: 26 + !(lib.isDerivation drv) 27 + || ( 28 + (name != "default") 29 + && ( 30 + ((drv.passthru.my.ci.build or false) == true) 31 + || (builtins.elem drv.system (drv.passthru.my.ci.buildFor or [])) 35 32 ) 36 - ); 37 - spreadBranchOrDefault = defaultBranches: infos: 38 - lib.concatMap 39 - (info: (lib.concatMap 40 - (branch: [(info // {inherit branch;})]) 41 - ( 42 - if (builtins.length info.branch > 0) 43 - then info.branch 44 - else defaultBranches 45 - ))) 46 - infos; 47 - ciInfo = { 48 - homeConfigurations = 49 - self.homeConfigurations 50 - |> lib.filterAttrs (_: home: home._module.specialArgs.osConfig == {}) # Standalone only 51 - |> filterToBuild 52 - |> getOutputInfo (name: ".#homeConfigurations.${name}.activationPackage") 53 - |> spreadBranchOrDefault []; 54 - nixosConfigurations = 55 - self.nixosConfigurations 56 - |> filterToBuild 57 - |> getOutputInfo (name: ".#nixosConfigurations.${name}.config.system.build.toplevel") 58 - |> spreadBranchOrDefault []; 59 - packages = 60 - self.packages 61 - |> filterPerSystemToBuild 62 - |> getPerSystemOutputInfo (system: name: ".#packages.${system}.${name}") 63 - |> spreadBranchOrDefault ["main" "develop"]; 64 - devShells = 65 - self.devShells 66 - |> filterPerSystemToBuild 67 - |> getPerSystemOutputInfo (system: name: ".#devShells.${system}.${name}") 68 - |> spreadBranchOrDefault ["main" "develop"]; 69 - }; 70 - in { 71 - legacyPackages.ciMatrix = 72 - ciInfo 73 - |> builtins.toJSON 74 - |> pkgs.writeText "ci-matrix"; 33 + ) 34 + ); 35 + spreadBranchOrDefault = defaultBranches: infos: 36 + lib.concatMap 37 + (info: (lib.concatMap 38 + (branch: [(info // {inherit branch;})]) 39 + ( 40 + if (builtins.length info.branch > 0) 41 + then info.branch 42 + else defaultBranches 43 + ))) 44 + infos; 45 + ciInfo = { 46 + homeConfigurations = 47 + homeConfigurations 48 + |> lib.filterAttrs (_: home: home._module.specialArgs.osConfig == {}) # Standalone only 49 + |> filterToBuild 50 + |> getOutputInfo (name: ".#homeConfigurations.${name}.activationPackage") 51 + |> spreadBranchOrDefault []; 52 + nixosConfigurations = 53 + nixosConfigurations 54 + |> filterToBuild 55 + |> getOutputInfo (name: ".#nixosConfigurations.${name}.config.system.build.toplevel") 56 + |> spreadBranchOrDefault []; 57 + packages = 58 + packages 59 + |> filterPerSystemToBuild 60 + |> getPerSystemOutputInfo (system: name: ".#packages.${system}.${name}") 61 + |> spreadBranchOrDefault ["main" "develop"]; 62 + devShells = 63 + devShells 64 + |> filterPerSystemToBuild 65 + |> getPerSystemOutputInfo (system: name: ".#devShells.${system}.${name}") 66 + |> spreadBranchOrDefault ["main" "develop"]; 75 67 }; 76 - } 68 + in 69 + ciInfo 70 + |> builtins.toJSON 71 + |> writeText "ci-matrix"
+20 -4
nix/legacyPackages/default.nix
··· 1 1 args: { 2 - imports = [ 3 - ./ciMatrix.nix 4 - ./scripts 5 - ]; 2 + perSystem = { 3 + lib, 4 + self', 5 + pkgs, 6 + ... 7 + }: let 8 + extraArgs = { 9 + inherit (args) inputs; 10 + inherit (self'.legacyPackages.pkgs) writeNuScriptStdinBin; 11 + }; 12 + callPackage = lib.callPackageWith (pkgs // extraArgs); 13 + in { 14 + legacyPackages = 15 + lib.packagesFromDirectoryRecursive { 16 + inherit callPackage; 17 + directory = ./.; 18 + } 19 + |> lib.filterAttrsRecursive (name: _: name != "default") 20 + |> (legacyPackages: legacyPackages // legacyPackages.scripts); 21 + }; 6 22 }
-20
nix/legacyPackages/scripts/default.nix
··· 1 - {inputs, ...}: let 2 - inherit (inputs.self.lib) nixFilesToAttrs; 3 - in { 4 - perSystem = { 5 - self', 6 - lib, 7 - pkgs, 8 - ... 9 - }: { 10 - legacyPackages = let 11 - callPackage = lib.callPackageWith pkgs; 12 - extraPkgs = {inherit (self'.legacyPackages.pkgs) writeNuScriptStdinBin;}; 13 - scripts = 14 - nixFilesToAttrs ./. 15 - |> lib.mapAttrs (_: path: callPackage path extraPkgs); 16 - in 17 - scripts # Provide them at the top level as well so they're more convenient to run 18 - // {inherit scripts;}; 19 - }; 20 - }
+6 -6
nix/packages/default.nix
··· 8 8 callPackage = lib.callPackageWith pkgs; 9 9 in { 10 10 packages = 11 - (lib.packagesFromDirectoryRecursive { 12 - inherit callPackage; 13 - directory = ./.; 14 - } 15 - |> lib.filterAttrs (name: _: name != "default")) 16 - // { 11 + lib.packagesFromDirectoryRecursive { 12 + inherit callPackage; 13 + directory = ./.; 14 + } 15 + |> lib.filterAttrsRecursive (name: _: name != "default") 16 + |> lib.recursiveUpdate { 17 17 lichen = 18 18 callPackage 19 19 ./lichen/package.nix