From 5410671050b3a2e460ad5cecf844f3554c98c2b5 Mon Sep 17 00:00:00 2001 From: xeals Date: Thu, 23 Feb 2023 11:46:04 +1100 Subject: [PATCH] all: embrace unit packages where possible --- flake.nix | 24 ++++++++++++++++--- pkgs/top-level/all-packages.nix | 23 ------------------ .../al/alacritty-ligatures/package.nix} | 0 .../am/amdgpu-fan/package.nix} | 0 .../at/atlauncher/package.nix} | 0 .../0001-use-system-dependencies.patch | 0 .../ca/cardboard/package.nix} | 0 .../li}/libhl/fix-link.patch | 0 .../default.nix => unit/li/libhl/package.nix} | 0 .../pa/pam_gnupg/package.nix} | 0 .../default.nix => unit/ps/psst/package.nix} | 0 .../sa/samrewritten/package.nix} | 0 .../sp}/spotify-ripper/fix-setup.patch | 0 .../sp/spotify-ripper/package.nix} | 0 .../yt/ytarchive/package.nix} | 0 .../default.nix => unit/zs/zsh-z/package.nix} | 0 16 files changed, 21 insertions(+), 26 deletions(-) rename pkgs/{applications/terminal-emulators/alacritty-ligatures/default.nix => unit/al/alacritty-ligatures/package.nix} (100%) rename pkgs/{tools/misc/amdgpu-fan/default.nix => unit/am/amdgpu-fan/package.nix} (100%) rename pkgs/{games/atlauncher/default.nix => unit/at/atlauncher/package.nix} (100%) rename pkgs/{applications/window-managers => unit/ca}/cardboard/0001-use-system-dependencies.patch (100%) rename pkgs/{applications/window-managers/cardboard/default.nix => unit/ca/cardboard/package.nix} (100%) rename pkgs/{development/libraries => unit/li}/libhl/fix-link.patch (100%) rename pkgs/{development/libraries/libhl/default.nix => unit/li/libhl/package.nix} (100%) rename pkgs/{os-specific/linux/pam_gnupg/default.nix => unit/pa/pam_gnupg/package.nix} (100%) rename pkgs/{applications/audio/psst/default.nix => unit/ps/psst/package.nix} (100%) rename pkgs/{tools/misc/samrewritten/default.nix => unit/sa/samrewritten/package.nix} (100%) rename pkgs/{tools/misc => unit/sp}/spotify-ripper/fix-setup.patch (100%) rename pkgs/{tools/misc/spotify-ripper/default.nix => unit/sp/spotify-ripper/package.nix} (100%) rename pkgs/{tools/misc/ytarchive/default.nix => unit/yt/ytarchive/package.nix} (100%) rename pkgs/{shells/zsh/zsh-z/default.nix => unit/zs/zsh-z/package.nix} (100%) diff --git a/flake.nix b/flake.nix index 9259520..a21531a 100644 --- a/flake.nix +++ b/flake.nix @@ -15,10 +15,28 @@ pkgs = import nixpkgs { inherit system; }; in { + # nixos/rfcs#140 + # Only produces the package set of the proposed functionality. + # Unstable names are variables. packages = - lib.filterAttrs - (_: drv: builtins.elem system (drv.meta.platforms or [ ])) - (import ./pkgs/top-level/all-packages.nix { inherit pkgs; }); + 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; }; + onlyAvailable = lib.filterAttrs (_: drv: builtins.elem system (drv.meta.platforms or [ ])); + in + onlyAvailable (legacyPackages // callUnitRoot "${./pkgs}/${unitDir}"); checks = { nixpkgs-fmt = pkgs.writeShellScriptBin "nixpkgs-fmt-check" '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8ac4065..13bc757 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1,15 +1,6 @@ { pkgs }: rec { - # Alacritty with the unmerged ligature patches applied. - alacritty-ligatures = pkgs.callPackage ../applications/terminal-emulators/alacritty-ligatures { }; - - atlauncher = pkgs.callPackage ../games/atlauncher { }; - - amdgpu-fan = pkgs.callPackage ../tools/misc/amdgpu-fan { }; - - cardboard = pkgs.callPackage ../applications/window-managers/cardboard { }; - goModules = pkgs.recurseIntoAttrs rec { qt = pkgs.libsForQt512.callPackage ../development/go-modules/qt { }; }; @@ -34,14 +25,10 @@ rec { ideaUltimateWithPlugins = ideaUltimatePlugins.jetbrainsWithPlugins; }; - libhl = pkgs.callPackage ../development/libraries/libhl { }; - mopidy-subidy = pkgs.callPackage ../applications/audio/mopidy/subidy.nix { python3Packages = pkgs.python3Packages // python3Packages; }; - pam_gnupg = pkgs.callPackage ../os-specific/linux/pam_gnupg { }; - picom-animations = pkgs.picom.overrideAttrs (_oldAttrs: { pname = "picom-animations"; src = pkgs.fetchFromGitHub { @@ -58,8 +45,6 @@ rec { patches = (oldAttrs.patches or [ ]) ++ [ ../applications/misc/polybar/9button.patch ]; }); - psst = pkgs.callPackage ../applications/audio/psst { }; - python3Packages = pkgs.recurseIntoAttrs { py-sonic = pkgs.python3.pkgs.callPackage ../development/python-modules/py-sonic { }; }; @@ -73,12 +58,4 @@ rec { protonmail-bridge-headless = protonmailBridgePackages.protonmail-bridge-headless; radeon-profile-daemon = pkgs.libsForQt5.callPackage ../tools/misc/radeon-profile-daemon { }; - - samrewritten = pkgs.callPackage ../tools/misc/samrewritten { }; - - spotify-ripper = pkgs.callPackage ../tools/misc/spotify-ripper { }; - - ytarchive = pkgs.callPackage ../tools/misc/ytarchive { }; - - zsh-z = pkgs.callPackage ../shells/zsh/zsh-z { }; } diff --git a/pkgs/applications/terminal-emulators/alacritty-ligatures/default.nix b/pkgs/unit/al/alacritty-ligatures/package.nix similarity index 100% rename from pkgs/applications/terminal-emulators/alacritty-ligatures/default.nix rename to pkgs/unit/al/alacritty-ligatures/package.nix diff --git a/pkgs/tools/misc/amdgpu-fan/default.nix b/pkgs/unit/am/amdgpu-fan/package.nix similarity index 100% rename from pkgs/tools/misc/amdgpu-fan/default.nix rename to pkgs/unit/am/amdgpu-fan/package.nix diff --git a/pkgs/games/atlauncher/default.nix b/pkgs/unit/at/atlauncher/package.nix similarity index 100% rename from pkgs/games/atlauncher/default.nix rename to pkgs/unit/at/atlauncher/package.nix diff --git a/pkgs/applications/window-managers/cardboard/0001-use-system-dependencies.patch b/pkgs/unit/ca/cardboard/0001-use-system-dependencies.patch similarity index 100% rename from pkgs/applications/window-managers/cardboard/0001-use-system-dependencies.patch rename to pkgs/unit/ca/cardboard/0001-use-system-dependencies.patch diff --git a/pkgs/applications/window-managers/cardboard/default.nix b/pkgs/unit/ca/cardboard/package.nix similarity index 100% rename from pkgs/applications/window-managers/cardboard/default.nix rename to pkgs/unit/ca/cardboard/package.nix diff --git a/pkgs/development/libraries/libhl/fix-link.patch b/pkgs/unit/li/libhl/fix-link.patch similarity index 100% rename from pkgs/development/libraries/libhl/fix-link.patch rename to pkgs/unit/li/libhl/fix-link.patch diff --git a/pkgs/development/libraries/libhl/default.nix b/pkgs/unit/li/libhl/package.nix similarity index 100% rename from pkgs/development/libraries/libhl/default.nix rename to pkgs/unit/li/libhl/package.nix diff --git a/pkgs/os-specific/linux/pam_gnupg/default.nix b/pkgs/unit/pa/pam_gnupg/package.nix similarity index 100% rename from pkgs/os-specific/linux/pam_gnupg/default.nix rename to pkgs/unit/pa/pam_gnupg/package.nix diff --git a/pkgs/applications/audio/psst/default.nix b/pkgs/unit/ps/psst/package.nix similarity index 100% rename from pkgs/applications/audio/psst/default.nix rename to pkgs/unit/ps/psst/package.nix diff --git a/pkgs/tools/misc/samrewritten/default.nix b/pkgs/unit/sa/samrewritten/package.nix similarity index 100% rename from pkgs/tools/misc/samrewritten/default.nix rename to pkgs/unit/sa/samrewritten/package.nix diff --git a/pkgs/tools/misc/spotify-ripper/fix-setup.patch b/pkgs/unit/sp/spotify-ripper/fix-setup.patch similarity index 100% rename from pkgs/tools/misc/spotify-ripper/fix-setup.patch rename to pkgs/unit/sp/spotify-ripper/fix-setup.patch diff --git a/pkgs/tools/misc/spotify-ripper/default.nix b/pkgs/unit/sp/spotify-ripper/package.nix similarity index 100% rename from pkgs/tools/misc/spotify-ripper/default.nix rename to pkgs/unit/sp/spotify-ripper/package.nix diff --git a/pkgs/tools/misc/ytarchive/default.nix b/pkgs/unit/yt/ytarchive/package.nix similarity index 100% rename from pkgs/tools/misc/ytarchive/default.nix rename to pkgs/unit/yt/ytarchive/package.nix diff --git a/pkgs/shells/zsh/zsh-z/default.nix b/pkgs/unit/zs/zsh-z/package.nix similarity index 100% rename from pkgs/shells/zsh/zsh-z/default.nix rename to pkgs/unit/zs/zsh-z/package.nix