mirror of
https://github.com/Smaug123/anki-decks
synced 2025-10-08 19:18:42 +00:00
Extract shell script
This commit is contained in:
18
flake.lock
generated
18
flake.lock
generated
@@ -90,7 +90,23 @@
|
|||||||
"inputs": {
|
"inputs": {
|
||||||
"anki-compiler": "anki-compiler",
|
"anki-compiler": "anki-compiler",
|
||||||
"flake-utils": "flake-utils_2",
|
"flake-utils": "flake-utils_2",
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2",
|
||||||
|
"scripts": "scripts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1696031019,
|
||||||
|
"narHash": "sha256-MuKEC8ZZ1Znm2idxQEQYU18z/1l9rjBZaj5gdKd9elQ=",
|
||||||
|
"owner": "Smaug123",
|
||||||
|
"repo": "flake-shell-script",
|
||||||
|
"rev": "05cc0582a193d3b42b6b4e64c6ec7a9bca4bb3c5",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "Smaug123",
|
||||||
|
"repo": "flake-shell-script",
|
||||||
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
|
36
flake.nix
36
flake.nix
@@ -5,6 +5,7 @@
|
|||||||
flake-utils.url = github:numtide/flake-utils;
|
flake-utils.url = github:numtide/flake-utils;
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
|
||||||
anki-compiler.url = "github:Smaug123/anki-dotnet";
|
anki-compiler.url = "github:Smaug123/anki-dotnet";
|
||||||
|
scripts.url = "github:Smaug123/flake-shell-script";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {
|
outputs = {
|
||||||
@@ -12,6 +13,7 @@
|
|||||||
nixpkgs,
|
nixpkgs,
|
||||||
flake-utils,
|
flake-utils,
|
||||||
anki-compiler,
|
anki-compiler,
|
||||||
|
scripts,
|
||||||
}: let
|
}: let
|
||||||
commit = self.shortRev or "dirty";
|
commit = self.shortRev or "dirty";
|
||||||
date = self.lastModifiedDate or self.lastModified or "19700101";
|
date = self.lastModifiedDate or self.lastModified or "19700101";
|
||||||
@@ -19,38 +21,6 @@
|
|||||||
in
|
in
|
||||||
flake-utils.lib.eachDefaultSystem (system: let
|
flake-utils.lib.eachDefaultSystem (system: let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
in let
|
|
||||||
createShellScript = name: contents:
|
|
||||||
pkgs.stdenv.mkDerivation {
|
|
||||||
__contentAddressed = true;
|
|
||||||
pname = name;
|
|
||||||
version = "0.1.0";
|
|
||||||
src = contents;
|
|
||||||
|
|
||||||
buildInputs = [
|
|
||||||
pkgs.shellcheck
|
|
||||||
];
|
|
||||||
|
|
||||||
phases = ["configurePhase" "buildPhase" "installPhase"];
|
|
||||||
|
|
||||||
configurePhase = ''
|
|
||||||
${pkgs.shellcheck}/bin/shellcheck "${contents}"
|
|
||||||
'';
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
cp "${contents}" run.sh
|
|
||||||
patchShebangs run.sh
|
|
||||||
sed -i 's_"/bin/bash"_"${pkgs.bash}/bin/bash"_' run.sh
|
|
||||||
sed -i 's_"/bin/sh"_"${pkgs.bash}/bin/bash"_' run.sh
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out
|
|
||||||
mv run.sh $out/run.sh
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
in let
|
|
||||||
buildAnki = createShellScript "anki" ./build.sh;
|
|
||||||
in {
|
in {
|
||||||
packages.default = pkgs.stdenv.mkDerivation {
|
packages.default = pkgs.stdenv.mkDerivation {
|
||||||
__contentAddressed = true;
|
__contentAddressed = true;
|
||||||
@@ -59,7 +29,7 @@
|
|||||||
src = ./.;
|
src = ./.;
|
||||||
buildInputs = [];
|
buildInputs = [];
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
${buildAnki}/run.sh . "${anki-compiler.packages.${system}.default}/bin/AnkiStatic" "$out"
|
${scripts.lib.createShellScript pkgs "anki" ./build.sh}/run.sh . "${anki-compiler.packages.${system}.default}/bin/AnkiStatic" "$out"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
|
Reference in New Issue
Block a user