Created
February 15, 2025 17:40
-
-
Save kuuote/377d939bf6966e32e8bbc041db345662 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "latte PoC"; | |
outputs = | |
{ | |
nixpkgs, | |
... | |
}: | |
let | |
inherit (nixpkgs) lib; | |
eachSystem = | |
fn: lib.genAttrs lib.systems.flakeExposed (system: fn nixpkgs.legacyPackages.${system}); | |
in | |
{ | |
latte = eachSystem (pkgs: { | |
default = { | |
gen = | |
args: | |
pkgs.linkFarm "template" { | |
"flake.nix" = ./flake.nix; | |
"flake.lock" = ./flake.lock; | |
text = pkgs.writeText "text" args.text or "no text"; | |
}; | |
}; | |
}); | |
}; | |
inputs = { | |
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
flake=${1:-.} | |
if [[ ! $flake =~ ":" ]]; then | |
flake=$(realpath $flake) | |
fi | |
system=$(nix eval --impure --raw --expr builtins.currentSystem) | |
cat > /tmp/latte.nix << EOS | |
let | |
flake = builtins.getFlake "${flake}"; | |
in | |
(flake.latte.${system}.default.gen { text = "hoge"; }) | |
EOS | |
outPath=$(nix build --no-link --print-out-paths --file /tmp/latte.nix) | |
cd $outPath | |
rm -rf /tmp/latte | |
mkdir -p /tmp/latte | |
find -L . -type f | sort | while read path; do | |
mkdir -p $(dirname /tmp/latte/$path) | |
cat $path > /tmp/latte/$path | |
echo Wrote $path | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment