nixos-configs/lib.nix
matt1432 0fa79307c1
All checks were successful
Discord / discord commits (push) Has been skipped
feat(ags): install node_modules in nix
2024-08-06 20:35:11 -04:00

84 lines
2 KiB
Nix

{...} @ inputs: rec {
mkVersion = src: "0.0.0+" + src.shortRev;
buildPlugin = pname: src:
inputs.pkgs.vimUtils.buildVimPlugin {
inherit pname src;
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 {
inherit system;
config.allowUnfree = true;
overlays =
(map (i: inputs.${i}.overlays.default) [
"discord-overlay"
"grim-hyprland"
"jovian"
"nixpkgs-wayland"
])
++ [
inputs.self.overlays.xdg-desktop-portal-kde
];
};
# Function that makes the attrs that make up the specialArgs
mkArgs = system:
inputs
// {
pkgs = mkPkgs system inputs.nixpkgs;
};
# Default system
mkNixOS = mods:
inputs.nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs = mkArgs system;
modules =
[
{home-manager.extraSpecialArgs = specialArgs;}
./common
]
++ mods;
};
mkNixOnDroid = mods:
inputs.nix-on-droid.lib.nixOnDroidConfiguration rec {
extraSpecialArgs = mkArgs "aarch64-linux";
home-manager-path = inputs.home-manager.outPath;
pkgs = extraSpecialArgs.pkgs;
modules =
[
{
options = with pkgs.lib; {
environment.variables.FLAKE = mkOption {
type = with types; nullOr str;
};
};
}
{home-manager = {inherit extraSpecialArgs;};}
./common/nix-on-droid.nix
]
++ mods;
};
}