feat(ags): install node_modules in nix
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
9ea4b26421
commit
0fa79307c1
9 changed files with 57 additions and 25 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,7 +2,7 @@
|
|||
*.egg-info
|
||||
|
||||
# NPM
|
||||
*node_modules/
|
||||
*node_modules
|
||||
*build/
|
||||
|
||||
# Direnv
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
{
|
||||
lib,
|
||||
system,
|
||||
buildNpmPackage,
|
||||
callPackage,
|
||||
makeWrapper,
|
||||
mozilla-addons-to-nix,
|
||||
nodejs_latest,
|
||||
...
|
||||
}: let
|
||||
|
@ -12,10 +10,9 @@
|
|||
inherit (builtins) readFile fromJSON;
|
||||
|
||||
packageJSON = fromJSON (readFile ./package.json);
|
||||
pname = packageJSON.name;
|
||||
in
|
||||
buildNpmPackage rec {
|
||||
name = pname;
|
||||
pname = packageJSON.name;
|
||||
inherit (packageJSON) version;
|
||||
|
||||
src = ./.;
|
||||
|
@ -23,7 +20,6 @@ in
|
|||
|
||||
runtimeInputs = [
|
||||
(callPackage ../../nixosModules/docker/updateImage.nix {})
|
||||
mozilla-addons-to-nix.packages.${system}.default
|
||||
];
|
||||
nativeBuildInputs = [makeWrapper];
|
||||
|
||||
|
|
17
lib.nix
17
lib.nix
|
@ -7,6 +7,23 @@
|
|||
version = mkVersion src;
|
||||
};
|
||||
|
||||
buildNodeModules = dir: npmDepsHash: let
|
||||
pkg = inputs.pkgs.callPackage ({buildNpmPackage, ...}: let
|
||||
inherit (builtins) readFile fromJSON;
|
||||
|
||||
packageJSON = fromJSON (readFile (dir + /package.json));
|
||||
in
|
||||
buildNpmPackage {
|
||||
pname = packageJSON.name;
|
||||
inherit (packageJSON) version;
|
||||
|
||||
src = dir;
|
||||
|
||||
inherit npmDepsHash;
|
||||
dontNpmBuild = true;
|
||||
}) {};
|
||||
in "${pkg}/lib/node_modules/${pkg.pname}/node_modules";
|
||||
|
||||
# Import pkgs from a nixpkgs
|
||||
mkPkgs = system: input:
|
||||
import input {
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
use flake "$FLAKE#node"
|
||||
npm ci
|
||||
|
|
BIN
nixosModules/ags/config/package-lock.json
generated
BIN
nixosModules/ags/config/package-lock.json
generated
Binary file not shown.
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"name": "ags-node-modules",
|
||||
"version": "0.0.0",
|
||||
"main": "config.js",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"fzf": "0.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"fzf": "0.5.2",
|
||||
"@eslint/js": "9.8.0",
|
||||
"@stylistic/eslint-plugin": "2.6.1",
|
||||
"@types/eslint__js": "8.42.3",
|
||||
"@types/node": "22.0.2",
|
||||
"@types/node": "22.1.0",
|
||||
"eslint": "9.8.0",
|
||||
"eslint-plugin-jsdoc": "48.10.2",
|
||||
"eslint-plugin-jsdoc": "48.11.0",
|
||||
"typescript": "5.5.4",
|
||||
"typescript-eslint": "8.0.0"
|
||||
"typescript-eslint": "8.0.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ in {
|
|||
inherit (lib) boolToString mkIf toLower;
|
||||
|
||||
# Configs
|
||||
inherit (config.vars) mainUser hostName;
|
||||
inherit (config.vars) hostName;
|
||||
cfgDesktop = config.roles.desktop;
|
||||
flakeDir = config.environment.variables.FLAKE;
|
||||
|
||||
|
@ -24,7 +24,7 @@ in {
|
|||
|
||||
services.upower.enable = true;
|
||||
|
||||
home-manager.users.${mainUser}.imports = [
|
||||
home-manager.users.${cfgDesktop.user}.imports = [
|
||||
ags.homeManagerModules.default
|
||||
|
||||
({
|
||||
|
@ -46,11 +46,11 @@ in {
|
|||
'';
|
||||
|
||||
agsPkg = config.programs.ags.finalPackage;
|
||||
agsConfigDir = "${removePrefix "/home/${mainUser}/" flakeDir}/nixosModules/ags";
|
||||
agsConfigDir = "${removePrefix "/home/${cfgDesktop.user}/" flakeDir}/nixosModules/ags";
|
||||
in {
|
||||
assertions = [
|
||||
{
|
||||
assertion = hasPrefix "/home/${mainUser}/" flakeDir;
|
||||
assertion = hasPrefix "/home/${cfgDesktop.user}/" flakeDir;
|
||||
message = ''
|
||||
Your $FLAKE environment variable needs to point to a directory in
|
||||
the main users' home to use the AGS module.
|
||||
|
@ -68,6 +68,8 @@ in {
|
|||
|
||||
home = {
|
||||
file = let
|
||||
inherit (import "${self}/lib.nix" {inherit pkgs;}) buildNodeModules;
|
||||
|
||||
mkType = package: girName: {
|
||||
"${agsConfigDir}/config/types/@girs/${toLower girName}".source =
|
||||
pkgs.callPackage
|
||||
|
@ -100,6 +102,9 @@ in {
|
|||
hasFprintd: ${boolToString (hostName == "wim")},
|
||||
};
|
||||
'';
|
||||
|
||||
"${agsConfigDir}/config/node_modules".source =
|
||||
buildNodeModules ./config "sha256-Jt7HRrQ8xrpkku51zFbJ44IgPaKKXerZBJUyjo5VudQ=";
|
||||
}
|
||||
// (import ./icons.nix {inherit pkgs agsConfigDir;})
|
||||
);
|
||||
|
|
|
@ -25,6 +25,15 @@ in {
|
|||
createHome = true;
|
||||
};
|
||||
|
||||
# Setup node modules for dev env
|
||||
home-manager.users.${cfg.user}.home.file = let
|
||||
flakeDir = config.environment.variables.FLAKE;
|
||||
modulesDir = "${lib.removePrefix "/home/${cfg.user}/" flakeDir}/nixosModules";
|
||||
nodeModules = config.home-manager.users.${cfg.user}.home.file."${modulesDir}/ags/config/node_modules".source;
|
||||
in {
|
||||
"${modulesDir}/desktop/manager/ags/node_modules".source = nodeModules;
|
||||
};
|
||||
|
||||
home-manager.users.greeter = {
|
||||
imports = [ags.homeManagerModules.default];
|
||||
|
||||
|
|
22
outputs.nix
22
outputs.nix
|
@ -135,14 +135,20 @@
|
|||
};
|
||||
|
||||
node = pkgs.mkShell {
|
||||
packages = with pkgs;
|
||||
[
|
||||
nodejs_latest
|
||||
typescript
|
||||
]
|
||||
++ (with nodePackages; [
|
||||
ts-node
|
||||
]);
|
||||
packages = with pkgs; [
|
||||
nodejs_latest
|
||||
typescript
|
||||
|
||||
(writeShellApplication {
|
||||
name = "updateNpmDeps";
|
||||
runtimeInputs = [prefetch-npm-deps nodejs_latest];
|
||||
|
||||
text = ''
|
||||
npm i --package-lock-only || true # this command will fail but still updates the main lockfile
|
||||
prefetch-npm-deps ./package-lock.json
|
||||
'';
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
subtitles-dev = pkgs.mkShell {
|
||||
|
|
Loading…
Reference in a new issue