Working NixOS package

main
Egor Ternovoy 2 weeks ago
parent c11c6e780a
commit 585b50d639
Signed by: cofob
GPG Key ID: ACAD4265E193794D
  1. 3
      .editorconfig
  2. 21
      flake.lock
  3. 32
      flake.nix
  4. 2
      package.json

@ -10,3 +10,6 @@ trim_trailing_whitespace = true
[*.yml]
indent_style = space
[*.nix]
indent_style = space

@ -1,5 +1,25 @@
{
"nodes": {
"bp": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1662627485,
"narHash": "sha256-Kg8u2ekU0+MsuLzgKqiaus3HquLLo2Qq+oGbQfIppos=",
"owner": "serokell",
"repo": "nix-npm-buildpackage",
"rev": "cab951dd024dd367511d48440de6f93664ee35aa",
"type": "github"
},
"original": {
"owner": "serokell",
"repo": "nix-npm-buildpackage",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1656928814,
@ -33,6 +53,7 @@
},
"root": {
"inputs": {
"bp": "bp",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}

@ -4,21 +4,47 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
bp.url = "github:serokell/nix-npm-buildpackage";
bp.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, ... }:
outputs = { self, nixpkgs, flake-utils, bp, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
yarn18 = pkgs.yarn.overrideAttrs (old: { buildInputs = [ pkgs.nodejs-18_x ]; });
node = pkgs.nodejs-18_x;
yarn18 = pkgs.yarn.overrideAttrs (old: { buildInputs = [ node ]; });
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
nodejs-18_x
node
yarn18
];
};
packages.default = bp.legacyPackages.x86_64-linux.buildYarnPackage {
src = ./.;
installPhase = ''
yarn build
rm -rf node_modules/
cat <<-END >> .yarnrc
yarn-offline-mirror "$PWD/yarn-cache"
nodedir "${node}"
END
yarn install --production --cache-folder "$PWD/yarn-cache" || true
cp -r build $out/
cp -r node_modules $out/
cp package.json $out/
cp yarn.lock $out/
mkdir $out/bin
cat <<EOF > $out/bin/cofob-ru
#!${pkgs.bash}/bin/bash
cd $out
${node}/bin/node $out/index.js
EOF
chmod u+x $out/bin/cofob-ru
'';
};
}
);
}

@ -8,7 +8,7 @@
"scripts": {
"dev": "vite dev",
"build": "DEPLOY_TARGET=node vite build",
"build:static": "DEPLOY_TARGET=static vite build && cp ./build/200.html ./build/ipfs-404.html",
"build:static": "DEPLOY_TARGET=static vite build && cp ./build/200.html ./build/ipfs-404.html && cp ./build/200.html ./build/index.html",
"build:cloudflare": "DEPLOY_TARGET=cloudflare vite build",
"package": "svelte-kit package",
"preview": "vite preview",

Loading…
Cancel
Save