fix nixpkgs command with latest nix version

This commit is contained in:
Jörg Thalheim
2024-10-22 12:38:01 +02:00
parent 78bf5b9147
commit eb0643f920
2 changed files with 29 additions and 19 deletions

6
flake.lock generated
View File

@@ -78,11 +78,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1728538411, "lastModified": 1729265718,
"narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", "narHash": "sha256-4HQI+6LsO3kpWTYuVGIzhJs1cetFcwT7quWCk/6rqeo=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", "rev": "ccc0c2126893dd20963580b6478d1a10a4512185",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -16,6 +16,7 @@
runCommand, runCommand,
setuptools, setuptools,
stdenv, stdenv,
nixVersions,
# custom args # custom args
clan-core-path, clan-core-path,
@@ -67,24 +68,33 @@ let
''; '';
# Create a custom nixpkgs for use within the project # Create a custom nixpkgs for use within the project
nixpkgs' = runCommand "nixpkgs" { nativeBuildInputs = [ nix ]; } ''
mkdir $out
cat > $out/flake.nix << EOF
{
description = "dependencies for the clan-cli";
inputs = { nixpkgs' =
nixpkgs.url = "path://${nixpkgs}"; runCommand "nixpkgs"
}; {
nativeBuildInputs = [
# old nix version doesn't support --flake flag
(if lib.versionAtLeast nix.version "2.24" then nix else nixVersions.latest)
];
}
''
mkdir $out
cat > $out/flake.nix << EOF
{
description = "dependencies for the clan-cli";
outputs = _inputs: { }; inputs = {
} nixpkgs.url = "path://${nixpkgs}";
EOF };
ln -sf ${nixpkgs} $out/path
nix flake update $out \ outputs = _inputs: { };
--store ./. \ }
--extra-experimental-features 'nix-command flakes' EOF
''; ln -sf ${nixpkgs} $out/path
HOME=$TMPDIR nix flake update --flake $out \
--store ./. \
--extra-experimental-features 'nix-command flakes'
'';
in in
python3.pkgs.buildPythonApplication { python3.pkgs.buildPythonApplication {
name = "clan-cli"; name = "clan-cli";