feat(nix): write a working nix flake

This commit is contained in:
Ivan R. 2024-02-23 22:17:15 +05:00
parent c91eccc036
commit 16b429be54
No known key found for this signature in database
GPG key ID: 56C7BAAE859B302C
2 changed files with 73 additions and 13 deletions

View file

@ -1,5 +1,23 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1708566995,
@ -18,8 +36,24 @@
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",

View file

@ -3,19 +3,45 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShells.${system}.default = pkgs.mkShell {
buildInputs = [
pkgs.nodejs_20
pkgs.imagemagick
];
};
};
outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
packageName = "comfycamp";
in
{
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.nodejs_20
pkgs.imagemagick
];
};
packages.${packageName} = pkgs.buildNpmPackage {
name = "${packageName}";
src = ./.;
npmDepsHash = "sha256-Nprdi+LX7/fSnrxeJzkbHX13FKM172E8wy6L+nxC/iE=";
buildInputs = [
pkgs.nodejs_20
pkgs.vips # required by sharp
];
nativeBuildInputs = [
pkgs.pkg-config # required by sharp
];
installPhase = ''
mkdir $out
npm run build
cp -r dist/* $out
'';
};
defaultPackage = self.packages.${system}.${packageName};
}
);
}