From d3e9a1b1d70e5352836b37aa2bce7f226fd6bdad Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sat, 23 Nov 2024 19:35:01 -0500 Subject: [PATCH] refactor(flake): expose appsPackages --- apps/default.nix | 2 +- apps/{ => nix}/buildApp.nix | 5 +++-- apps/nix/packages.nix | 14 ++++++++++++++ checks/apps/default.nix | 9 +++------ outputs.nix | 6 +++++- 5 files changed, 26 insertions(+), 10 deletions(-) rename apps/{ => nix}/buildApp.nix (82%) create mode 100644 apps/nix/packages.nix diff --git a/apps/default.nix b/apps/default.nix index c514fa0f..5d039cfc 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -5,7 +5,7 @@ }: let inherit (pkgs.lib) getExe listToAttrs nameValuePair; - buildApp = attrs: (pkgs.callPackage ./buildApp.nix ({} // inputs // attrs)); + buildApp = attrs: (pkgs.callPackage ./nix/buildApp.nix ({} // inputs // attrs)); mkApp = file: { program = getExe (pkgs.callPackage file ({inherit buildApp;} // inputs)); diff --git a/apps/buildApp.nix b/apps/nix/buildApp.nix similarity index 82% rename from apps/buildApp.nix rename to apps/nix/buildApp.nix index f15d1a27..9094b81c 100644 --- a/apps/buildApp.nix +++ b/apps/nix/buildApp.nix @@ -10,8 +10,9 @@ ... }: let inherit (lib) concatMapStringsSep getBin; + inherit (builtins) fromJSON readFile; - packageJSON = builtins.fromJSON (builtins.readFile "${src}/package.json"); + packageJSON = fromJSON (readFile "${src}/package.json"); in buildNpmPackage rec { pname = packageJSON.name; @@ -21,7 +22,7 @@ in prePatch = '' mv ./tsconfig.json ./project.json - sed 's/^ *\/\/.*//' ${./tsconfig.json} > ./base.json + sed 's/^ *\/\/.*//' ${../tsconfig.json} > ./base.json ${jq}/bin/jq -sr '.[0] * .[1] | del(.extends)' ./project.json ./base.json > ./tsconfig.json rm base.json project.json ''; diff --git a/apps/nix/packages.nix b/apps/nix/packages.nix new file mode 100644 index 00000000..dc41fb8e --- /dev/null +++ b/apps/nix/packages.nix @@ -0,0 +1,14 @@ +{ + pkgs, + self, + ... +}: let + inherit (pkgs.lib) mapAttrs removeSuffix; +in + mapAttrs ( + name: app: (pkgs.symlinkJoin { + name = "app-${name}"; + paths = [(removeSuffix "/bin/${name}" (toString app.program))]; + }) + ) + (removeAttrs self.apps.${pkgs.system} ["genflake"]) diff --git a/checks/apps/default.nix b/checks/apps/default.nix index 00354f0b..a74c56b1 100644 --- a/checks/apps/default.nix +++ b/checks/apps/default.nix @@ -2,12 +2,9 @@ pkgs, self, }: let - inherit (pkgs.lib) mapAttrs' nameValuePair removeAttrs removeSuffix; + inherit (pkgs.lib) mapAttrs' nameValuePair; in mapAttrs' (name: app: - nameValuePair "app-${name}" (pkgs.symlinkJoin { - name = "app-${name}"; - paths = [(removeSuffix "/bin/${name}" (toString app.program))]; - })) - (removeAttrs self.apps.${pkgs.system} ["genflake"]) + nameValuePair "app-${name}" app) + self.appsPackages.${pkgs.system} diff --git a/outputs.nix b/outputs.nix index 1a3d5918..7af4c7e1 100644 --- a/outputs.nix +++ b/outputs.nix @@ -143,6 +143,10 @@ perSystem (pkgs: import ./apps {inherit inputs pkgs;}); + appsPackages = + perSystem (pkgs: + import ./apps/nix/packages.nix {inherit pkgs self;}); + devShells = perSystem (pkgs: let bumpNpmDeps = pkgs.writeShellApplication { name = "bumpNpmDeps"; @@ -174,7 +178,7 @@ sudo sed -i -e "/^$GROUP:/d" /etc/group # Remove generated group entry sudo find / -gid "$OLD_GID" -exec chgrp "$NEW_GID" {} + # Change GID on existing files - sudo nixos-rebuild --switch # Regenerate /etc/group with new GID + exec nh os switch # Regenerate /etc/group with new GID ''; }) ];