1{ stdenv, lib, nixos-container, openssh, glibcLocales, fetchFromGitHub }:
2
3stdenv.mkDerivation rec {
4 pname = "extra-container";
5 version = "0.8";
6
7 src = fetchFromGitHub {
8 owner = "erikarvstedt";
9 repo = pname;
10 rev = version;
11 hash = "sha256-/AetqDPkz32JMdjbSdzZCBVmGbvzjeAb8Wv82iTgHFE=";
12 };
13
14 buildCommand = ''
15 install -D $src/extra-container $out/bin/extra-container
16 patchShebangs $out/bin
17 share=$out/share/extra-container
18 install $src/eval-config.nix -Dt $share
19
20 # Use existing PATH for systemctl and machinectl
21 scriptPath="export PATH=${lib.makeBinPath [ nixos-container openssh ]}:\$PATH"
22
23 sed -i \
24 -e "s|evalConfig=.*|evalConfig=$share/eval-config.nix|" \
25 -e "s|LOCALE_ARCHIVE=.*|LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive|" \
26 -e "2i$scriptPath" \
27 $out/bin/extra-container
28 '';
29
30 meta = with lib; {
31 description = "Run declarative containers without full system rebuilds";
32 homepage = "https://github.com/erikarvstedt/extra-container";
33 license = licenses.mit;
34 platforms = platforms.linux;
35 maintainers = [ maintainers.earvstedt ];
36 };
37}