package as flake

This commit is contained in:
shimun 2021-01-02 11:12:23 +01:00
commit f877703a3a
Signed by: shimun
GPG Key ID: E81D8382DC2F971B
2 changed files with 138 additions and 0 deletions

78
flake.lock generated Normal file
View File

@ -0,0 +1,78 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1609246779,
"narHash": "sha256-eq6ZXE/VWo3EMC65jmIT6H/rrUc9UWOWVujkzav025k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "08c7ad4a0844adc4a7f9f5bb3beae482e789afa4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nix-extras": {
"flake": false,
"locked": {
"lastModified": 1574214871,
"narHash": "sha256-agE1aUir8UdqMJVyz2Xhe+jAR1AG1kmlF5mEHdHYmB4=",
"owner": "colehaus",
"repo": "nix-extras",
"rev": "f33ab8f70982073b08c67e0d4f6144d029f0441d",
"type": "github"
},
"original": {
"owner": "colehaus",
"repo": "nix-extras",
"rev": "f33ab8f70982073b08c67e0d4f6144d029f0441d",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1603791972,
"narHash": "sha256-nj2SvACFH+NERpye1kudcuygCcvnsZYv26M2+wgM5vE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cd63096d6d887d689543a0b97743d28995bc9bc3",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "20.09",
"type": "indirect"
}
},
"resume-cli": {
"flake": false,
"locked": {
"lastModified": 1604144818,
"narHash": "sha256-O38vYzA+N8YYNArkdStvTBks8aFQm44W7o8/k6w2S/Q=",
"owner": "jsonresume",
"repo": "resume-cli",
"rev": "7fb40dab8ca6aa519bd3c4ac2729b9fa4256cdcb",
"type": "github"
},
"original": {
"owner": "jsonresume",
"repo": "resume-cli",
"rev": "7fb40dab8ca6aa519bd3c4ac2729b9fa4256cdcb",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nix-extras": "nix-extras",
"nixpkgs": "nixpkgs",
"resume-cli": "resume-cli"
}
}
},
"root": "root",
"version": 7
}

60
flake.nix Normal file
View File

@ -0,0 +1,60 @@
{
description = "CLI tool to easily setup a new resume";
inputs = {
nix-extras = {
url = "github:colehaus/nix-extras/f33ab8f70982073b08c67e0d4f6144d029f0441d";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
resume-cli = {
url = "github:jsonresume/resume-cli/7fb40dab8ca6aa519bd3c4ac2729b9fa4256cdcb";
flake = false;
inputs.nixpkgs.follows = "nixpkgs";
};
# be careful when updating nixpkgs, resume-cli depends on the chromium ABI
nixpkgs.url = "nixpkgs/20.09";
};
outputs = { self, nixpkgs, resume-cli, nix-extras, flake-utils }: flake-utils.lib.eachSystem [ "x86_64-linux" ]
(system:
let
pkgs = import nixpkgs {
inherit system;
};
dbg = pkgs.lib.traceVal;
callNode2nix = import "${nix-extras}/callNode2nix.nix";
node2nix = callNode2nix { inherit pkgs; name = "resume-cli"; package = "${resume-cli}/package.json"; packageLock = "${resume-cli}/package-lock.json"; };
nixifiedSrc =
with pkgs;
(runCommandLocal "node2nix-merge" { } ''
mkdir -p $out
cp -r ${resume-cli}/* $out
cp -rf ${node2nix}/* $out/
''
);
nodePackages = pkgs.callPackage "${nixifiedSrc}" { inherit pkgs system; };
override = nodePackages // {
package = nodePackages.package.override {
PUPPETEER_SKIP_DOWNLOAD = 1;
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = 1;
buildInputs = [ pkgs.chromium ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram $out/bin/resume \
--set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium.outPath}/bin/chromium
'';
};
};
in
rec {
packages.resume-cli = override.package;
defaultPackage = packages.resume-cli;
apps.resume-cli = flake-utils.lib.mkApp { drv = defaultPackage; exePath = "/bin/resume"; };
defaultApp = apps.resume-cli;
devShell = with pkgs; mkShell {
buildInputs = [ nodejs packages.resume-cli ];
};
});
}