Cleanup flake.nix for wider compatibility

This commit is contained in:
Vincent Berthier 2025-02-19 22:21:57 +01:00
parent cc7bf71440
commit 5d384e3aa6
No known key found for this signature in database
2 changed files with 142 additions and 185 deletions

62
flake.lock generated
View File

@ -1,45 +1,12 @@
{
"nodes": {
"crane": {
"locked": {
"lastModified": 1739638817,
"narHash": "sha256-pPiI27T416xAAUETorkLAgHQMiLT92moOrf0ItHhtPA=",
"owner": "ipetkov",
"repo": "crane",
"rev": "bef2b45cd1273a9e621fb5292de89f4ed59ad812",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1739512841,
"narHash": "sha256-Zc+K4AxAwFaWKK18nSl/3TKidGf46En7bfK8SL+Revg=",
"lastModified": 1739863612,
"narHash": "sha256-UbtgxplOhFcyjBcNbTVO8+HUHAl/WXFDOb6LvqShiZo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fada727ee7c0bd487e311dede0a2b0725a0f7765",
"rev": "632f04521e847173c54fa72973ec6c39a371211c",
"type": "github"
},
"original": {
@ -51,8 +18,6 @@
},
"root": {
"inputs": {
"crane": "crane",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
@ -64,11 +29,11 @@
]
},
"locked": {
"lastModified": 1739673031,
"narHash": "sha256-Z/GT8ebbvc4goxN4A0A5ACj26G1HaGJO+VetrPuC5Mo=",
"lastModified": 1739932111,
"narHash": "sha256-WkayjH0vuGw0hx2gmjTUGFRvMKpM17gKcpL/U8EUUw0=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "538528d55318e0c8af1c307dcf10b7629b988fc3",
"rev": "75b2271c5c087d830684cd5462d4410219acc367",
"type": "github"
},
"original": {
@ -76,21 +41,6 @@
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",

265
flake.nix
View File

@ -12,72 +12,54 @@
nixpkgs.follows = "nixpkgs";
};
};
crane = {
url = "github:ipetkov/crane";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
rust-overlay,
crane,
} @ inputs:
flake-utils.lib.eachSystem ["x86_64-linux" "aarch64-linux"] (system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {
inherit system overlays;
};
inherit (pkgs) lib;
rust-bin =
pkgs.rust-bin.nightly."2025-01-12".default.override
{
extensions = ["rust-analyzer" "rust-src"];
...
} @ inputs: let
supportedSystems = [
"i686-linux"
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: (forSystem system f));
forSystem = system: f:
f rec {
inherit system;
pkgs = import nixpkgs {
inherit system;
overlays = [(import inputs.rust-overlay)];
};
lib = pkgs.lib;
rust-bin = pkgs.rust-bin.nightly."2025-01-12".default.override {
extensions = [
"rust-analyzer"
"rust-src"
];
targets = ["x86_64-unknown-redox"];
};
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rust-bin;
};
in {
formatter = forAllSystems ({pkgs, ...}: pkgs.nixfmt-rfc-style);
devShells = forAllSystems (
{
system,
pkgs,
rust-bin,
...
}: let
rustPlatform = pkgs.makeRustPlatform {
cargo = rust-bin;
rustc = rust-bin;
};
# Podman config taken from https://nixos.wiki/wiki/Podman and https://gist.github.com/adisbladis/187204cb772800489ee3dac4acdd9947
# Provides a script that copies required files to ~/
podmanSetupScript = let
registriesConf = pkgs.writeText "registries.conf" ''
[registries.search]
registries = ['docker.io']
[registries.block]
registries = []
'';
in
pkgs.writeScript "podman-setup" ''
#!${pkgs.runtimeShell}
# Dont overwrite customised configuration
if ! test -f ~/.config/containers/policy.json; then
install -Dm555 ${pkgs.skopeo.src}/default-policy.json ~/.config/containers/policy.json
fi
if ! test -f ~/.config/containers/registries.conf; then
install -Dm555 ${registriesConf} ~/.config/containers/registries.conf
fi
systemctl --user start podman.socket || true
export PODMAN_SYSTEMD_UNIT=podman.socket
'';
# Provides a fake "docker" binary mapping to podman
dockerCompat = pkgs.runCommandNoCC "docker-podman-compat" {} ''
mkdir -p $out/bin
ln -s ${pkgs.podman}/bin/podman $out/bin/docker
'';
cargo-config =
craneLib.buildPackage
{
cargo-config = rustPlatform.buildRustPackage {
pname = "cargo-config";
version = "0.1.1";
cargoArtifacts = null;
src = pkgs.fetchFromGitHub {
owner = "wesleywiser";
repo = "cargo-config";
@ -85,86 +67,109 @@
sha256 = "sha256-HrITNTfjBppOH1MhfZHfzHc6N8ymcm7vaiBI94ctUOA=";
fetchSubmodules = true;
};
# useFetchCargoVendor = true; # this is recommended, but fails in some python code?
cargoHash = "sha256-yQpIKclZ8KLE5JGkB/tjKZA8ezaD9SbUthDsuBXYZjQ=";
};
buildInputs = with pkgs; [
# Compilation
rust-bin
# Podman config taken from https://nixos.wiki/wiki/Podman and https://gist.github.com/adisbladis/187204cb772800489ee3dac4acdd9947
# Provides a script that copies required files to ~/
podmanSetupScript = let
registriesConf = pkgs.writeText "registries.conf" ''
[registries.search]
registries = ['docker.io']
[registries.block]
registries = []
'';
in
pkgs.writeScript "podman-setup" ''
#!${pkgs.runtimeShell}
# Dont overwrite customised configuration
if ! test -f ~/.config/containers/policy.json; then
install -Dm555 ${pkgs.skopeo.src}/default-policy.json ~/.config/containers/policy.json
fi
if ! test -f ~/.config/containers/registries.conf; then
install -Dm555 ${registriesConf} ~/.config/containers/registries.conf
fi
systemctl --user start podman.socket || true
export PODMAN_SYSTEMD_UNIT=podman.socket
'';
# Provides a fake "docker" binary mapping to podman
dockerCompat = pkgs.runCommandNoCC "docker-podman-compat" {} ''
mkdir -p $out/bin
ln -s ${pkgs.podman}/bin/podman $out/bin/docker
'';
# Utils
cowsay
lolcat
tokio-console
buildInputs = with pkgs; [
# Compilation
rust-bin
# Cargo utilities
bacon
cargo-bloat # check binaries size (which is fun but not terriby useful?)
cargo-cache # cargo cache -a
cargo-config
cargo-expand # for macro expension
cargo-spellcheck # Spellcheck documentation
# Utils
cowsay
lolcat
# Podman
dockerCompat
podman # Docker compat
runc # Container runtime
conmon # Container runtime monitor
skopeo # Interact with container registry
slirp4netns # User-mode networking for unprivileged namespaces
fuse-overlayfs # CoW for images, much faster than default vfs
# Cargo utilities
cargo-config
# Build Redox
ant
autoconf
automake
bison
cmake
curl
doxygen
expat
expect
file
flex
fuse
gmp
gnumake
gnupatch
gperf
just
libjpeg
libpng
libtool
llvmPackages.clang
llvmPackages.llvm
lua
m4
meson
nasm
perl
perl540Packages.HTMLParser
perl540Packages.Po4a
pkgconf
podman
protobuf
(python3.withPackages (ps: with ps; [mako]))
qemu_kvm
rust-cbindgen
scons
SDL
syslinux
texinfo
unzip
waf
wget
xdg-utils
zip
];
in {
devShells.default = with pkgs;
mkShell {
# Podman
dockerCompat
podman # Docker compat
runc # Container runtime
conmon # Container runtime monitor
skopeo # Interact with container registry
slirp4netns # User-mode networking for unprivileged namespaces
fuse-overlayfs # CoW for images, much faster than default vfs
# Build Redox
ant
autoconf
automake
bison
cmake
curl
doxygen
expat
expect
file
flex
fuse
gmp
gnumake
gnupatch
gperf
just
libjpeg
libpng
libtool
llvmPackages.clang
llvmPackages.llvm
lua
m4
meson
nasm
perl
perl540Packages.HTMLParser
perl540Packages.Po4a
pkgconf
podman
protobuf
(python3.withPackages (ps: with ps; [mako]))
qemu_kvm
rust-cbindgen
scons
SDL
syslinux
texinfo
unzip
waf
wget
xdg-utils
zip
];
in {
default = pkgs.mkShell {
inherit buildInputs;
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
NIX_SHELL_BUILD = "1";
shellHook = ''
# Install required configuration
@ -172,5 +177,7 @@
echo "Redox environment loaded" | cowsay | lolcat
'';
};
});
}
);
};
}