refactor(flake): expose appsPackages
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-11-23 19:35:01 -05:00
parent 5dd3f3f4e6
commit d3e9a1b1d7
5 changed files with 26 additions and 10 deletions

View file

@ -5,7 +5,7 @@
}: let }: let
inherit (pkgs.lib) getExe listToAttrs nameValuePair; 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: { mkApp = file: {
program = getExe (pkgs.callPackage file ({inherit buildApp;} // inputs)); program = getExe (pkgs.callPackage file ({inherit buildApp;} // inputs));

View file

@ -10,8 +10,9 @@
... ...
}: let }: let
inherit (lib) concatMapStringsSep getBin; inherit (lib) concatMapStringsSep getBin;
inherit (builtins) fromJSON readFile;
packageJSON = builtins.fromJSON (builtins.readFile "${src}/package.json"); packageJSON = fromJSON (readFile "${src}/package.json");
in in
buildNpmPackage rec { buildNpmPackage rec {
pname = packageJSON.name; pname = packageJSON.name;
@ -21,7 +22,7 @@ in
prePatch = '' prePatch = ''
mv ./tsconfig.json ./project.json 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 ${jq}/bin/jq -sr '.[0] * .[1] | del(.extends)' ./project.json ./base.json > ./tsconfig.json
rm base.json project.json rm base.json project.json
''; '';

14
apps/nix/packages.nix Normal file
View file

@ -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"])

View file

@ -2,12 +2,9 @@
pkgs, pkgs,
self, self,
}: let }: let
inherit (pkgs.lib) mapAttrs' nameValuePair removeAttrs removeSuffix; inherit (pkgs.lib) mapAttrs' nameValuePair;
in in
mapAttrs' mapAttrs'
(name: app: (name: app:
nameValuePair "app-${name}" (pkgs.symlinkJoin { nameValuePair "app-${name}" app)
name = "app-${name}"; self.appsPackages.${pkgs.system}
paths = [(removeSuffix "/bin/${name}" (toString app.program))];
}))
(removeAttrs self.apps.${pkgs.system} ["genflake"])

View file

@ -143,6 +143,10 @@
perSystem (pkgs: perSystem (pkgs:
import ./apps {inherit inputs pkgs;}); import ./apps {inherit inputs pkgs;});
appsPackages =
perSystem (pkgs:
import ./apps/nix/packages.nix {inherit pkgs self;});
devShells = perSystem (pkgs: let devShells = perSystem (pkgs: let
bumpNpmDeps = pkgs.writeShellApplication { bumpNpmDeps = pkgs.writeShellApplication {
name = "bumpNpmDeps"; name = "bumpNpmDeps";
@ -174,7 +178,7 @@
sudo sed -i -e "/^$GROUP:/d" /etc/group # Remove generated group entry 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 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
''; '';
}) })
]; ];