Compare commits

..

2 Commits

Author SHA1 Message Date
4586c00f4e
ci: bump cachix/install-nix-action 2023-03-06 09:49:33 +11:00
Alper Çelik
162045b8d7
default: add unit packages (#26) 2023-03-06 09:40:35 +11:00
5 changed files with 16 additions and 18 deletions

View File

@ -14,7 +14,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- uses: cachix/install-nix-action@v19 - uses: cachix/install-nix-action@v20
- name: Check ${{ matrix.check }} - name: Check ${{ matrix.check }}
# Depends on nixos/nix#7759 to simply `nix flake check` # Depends on nixos/nix#7759 to simply `nix flake check`
run: nix run .#checks.$(nix eval --raw --impure --expr "builtins.currentSystem").${{ matrix.check }} run: nix run .#checks.$(nix eval --raw --impure --expr "builtins.currentSystem").${{ matrix.check }}
@ -45,7 +45,7 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install nix - name: Install nix
uses: cachix/install-nix-action@v19 uses: cachix/install-nix-action@v20
- name: Show nixpkgs version - name: Show nixpkgs version
run: nix eval --impure --expr '(import ./flake-compat.nix { src = ./.; }).lib.version' run: nix eval --impure --expr '(import ./flake-compat.nix { src = ./.; }).lib.version'
- name: Setup cachix - name: Setup cachix

View File

@ -12,7 +12,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- uses: cachix/install-nix-action@v19 - uses: cachix/install-nix-action@v20
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}

10
callUnitRoot.nix Normal file
View File

@ -0,0 +1,10 @@
{ pkgs, lib ? pkgs.lib, unitDir ? "unit", packageFun ? "package.nix", root ? "${./pkgs}/${unitDir}" }:
let
shards = lib.attrNames (builtins.readDir root);
namesForShard = shard: lib.mapAttrs'
(name: _: { inherit name; value = "${root}/${shard}/${name}"; })
(builtins.readDir "${root}/${shard}");
namesToPath = lib.foldl' lib.recursiveUpdate { } (map namesForShard shards);
units = lib.mapAttrs (_: path: pkgs.callPackage "${path}/${packageFun}" { }) namesToPath;
in
units

View File

@ -14,4 +14,4 @@ import ./pkgs/top-level/all-packages.nix { inherit pkgs; }
lib = import ./lib { inherit pkgs; }; # functions lib = import ./lib { inherit pkgs; }; # functions
modules = import ./modules; # NixOS modules modules = import ./modules; # NixOS modules
overlays = import ./overlays; # nixpkgs overlays overlays = import ./overlays; # nixpkgs overlays
} } // import ./callUnitRoot.nix { inherit pkgs; }

View File

@ -20,23 +20,11 @@
# Unstable names are variables. # Unstable names are variables.
packages = packages =
let let
unitDir = "unit";
packageFun = "package.nix";
callUnitRoot = root:
let
shards = lib.attrNames (builtins.readDir root);
namesForShard = shard: lib.mapAttrs'
(name: _: { inherit name; value = "${root}/${shard}/${name}"; })
(builtins.readDir "${root}/${shard}");
namesToPath = lib.foldl' lib.recursiveUpdate { } (map namesForShard shards);
units = lib.mapAttrs (_: path: pkgs.callPackage "${path}/${packageFun}" { }) namesToPath;
in
units;
legacyPackages = import ./pkgs/top-level/all-packages.nix { inherit pkgs; }; legacyPackages = import ./pkgs/top-level/all-packages.nix { inherit pkgs; };
onlyAvailable = lib.filterAttrs (_: drv: builtins.elem system (drv.meta.platforms or [ ])); onlyAvailable = lib.filterAttrs (_: drv: builtins.elem system (drv.meta.platforms or [ ]));
in in
onlyAvailable (legacyPackages // callUnitRoot "${./pkgs}/${unitDir}"); onlyAvailable (legacyPackages // import ./callUnitRoot.nix { inherit pkgs; });
checks = { checks = {
nixpkgs-fmt = pkgs.writeShellScriptBin "nixpkgs-fmt-check" '' nixpkgs-fmt = pkgs.writeShellScriptBin "nixpkgs-fmt-check" ''