using flakes for devshell without reimporting nixpkgs multiple times
This commit is contained in:
@@ -1 +1 @@
|
|||||||
use nix
|
use flake .#clan
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
{ pkgs ? import <nixpkgs> { }
|
{ pkgs
|
||||||
, lib ? pkgs.lib
|
, lib
|
||||||
, python3 ? pkgs.python3
|
, python3
|
||||||
, ruff ? pkgs.ruff
|
, ruff
|
||||||
, runCommand ? pkgs.runCommand
|
, runCommand
|
||||||
, installShellFiles ? pkgs.installShellFiles
|
, installShellFiles
|
||||||
, zerotierone ? pkgs.zerotierone
|
, zerotierone
|
||||||
, bubblewrap ? pkgs.bubblewrap
|
, bubblewrap
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
pyproject = builtins.fromTOML (builtins.readFile ./pyproject.toml);
|
pyproject = builtins.fromTOML (builtins.readFile ./pyproject.toml);
|
||||||
|
|||||||
@@ -4,9 +4,11 @@
|
|||||||
pyproject = builtins.fromTOML (builtins.readFile ./pyproject.toml);
|
pyproject = builtins.fromTOML (builtins.readFile ./pyproject.toml);
|
||||||
name = pyproject.project.name;
|
name = pyproject.project.name;
|
||||||
package = pkgs.callPackage ./default.nix { };
|
package = pkgs.callPackage ./default.nix { };
|
||||||
|
shell = pkgs.callPackage ./shell.nix { };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages.${name} = package;
|
packages.${name} = package;
|
||||||
|
devShells.${name} = shell;
|
||||||
packages.default = package;
|
packages.default = package;
|
||||||
checks = package.tests;
|
checks = package.tests;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
{ pkgs ? import <nixpkgs> { }
|
{ pkgs }:
|
||||||
,
|
|
||||||
}:
|
|
||||||
let
|
let
|
||||||
lib = pkgs.lib;
|
package = pkgs.callPackage ./default.nix { };
|
||||||
python3 = pkgs.python3;
|
pythonWithDeps = pkgs.python3.withPackages (
|
||||||
package = import ./default.nix {
|
|
||||||
inherit lib python3;
|
|
||||||
};
|
|
||||||
pythonWithDeps = python3.withPackages (
|
|
||||||
ps:
|
ps:
|
||||||
package.propagatedBuildInputs
|
package.propagatedBuildInputs
|
||||||
++ package.devDependencies
|
++ package.devDependencies
|
||||||
@@ -18,39 +12,38 @@ let
|
|||||||
checkScript = pkgs.writeScriptBin "check" ''
|
checkScript = pkgs.writeScriptBin "check" ''
|
||||||
nix build -f . tests -L "$@"
|
nix build -f . tests -L "$@"
|
||||||
'';
|
'';
|
||||||
devShell = pkgs.mkShell {
|
|
||||||
packages = [
|
|
||||||
pkgs.ruff
|
|
||||||
pythonWithDeps
|
|
||||||
];
|
|
||||||
# sets up an editable install and add enty points to $PATH
|
|
||||||
CLAN_NIXPKGS = pkgs.path;
|
|
||||||
shellHook = ''
|
|
||||||
tmp_path=$(realpath ./.pythonenv)
|
|
||||||
repo_root=$(realpath .)
|
|
||||||
rm -rf $tmp_path
|
|
||||||
mkdir -p "$tmp_path/${pythonWithDeps.sitePackages}"
|
|
||||||
|
|
||||||
${pythonWithDeps.interpreter} -m pip install \
|
|
||||||
--quiet \
|
|
||||||
--disable-pip-version-check \
|
|
||||||
--no-index \
|
|
||||||
--no-build-isolation \
|
|
||||||
--prefix "$tmp_path" \
|
|
||||||
--editable $repo_root
|
|
||||||
|
|
||||||
export PATH="$tmp_path/bin:${checkScript}/bin:$PATH"
|
|
||||||
export PYTHONPATH="$repo_root:$tmp_path/${pythonWithDeps.sitePackages}"
|
|
||||||
|
|
||||||
export XDG_DATA_DIRS="$tmp_path/share''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
|
|
||||||
export fish_complete_path="$tmp_path/share/fish/vendor_completions.d''${fish_complete_path:+:$fish_complete_path}"
|
|
||||||
mkdir -p \
|
|
||||||
$tmp_path/share/fish/vendor_completions.d \
|
|
||||||
$tmp_path/share/bash-completion/completions \
|
|
||||||
$tmp_path/share/zsh/site-functions
|
|
||||||
register-python-argcomplete --shell fish clan > $tmp_path/share/fish/vendor_completions.d/clan.fish
|
|
||||||
register-python-argcomplete --shell bash clan > $tmp_path/share/bash-completion/completions/clan
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
devShell
|
pkgs.mkShell {
|
||||||
|
packages = [
|
||||||
|
pkgs.ruff
|
||||||
|
pythonWithDeps
|
||||||
|
];
|
||||||
|
# sets up an editable install and add enty points to $PATH
|
||||||
|
CLAN_NIXPKGS = pkgs.path;
|
||||||
|
shellHook = ''
|
||||||
|
tmp_path=$(realpath ./.pythonenv)
|
||||||
|
repo_root=$(realpath .)
|
||||||
|
rm -rf $tmp_path
|
||||||
|
mkdir -p "$tmp_path/${pythonWithDeps.sitePackages}"
|
||||||
|
|
||||||
|
${pythonWithDeps.interpreter} -m pip install \
|
||||||
|
--quiet \
|
||||||
|
--disable-pip-version-check \
|
||||||
|
--no-index \
|
||||||
|
--no-build-isolation \
|
||||||
|
--prefix "$tmp_path" \
|
||||||
|
--editable $repo_root
|
||||||
|
|
||||||
|
export PATH="$tmp_path/bin:${checkScript}/bin:$PATH"
|
||||||
|
export PYTHONPATH="$repo_root:$tmp_path/${pythonWithDeps.sitePackages}"
|
||||||
|
|
||||||
|
export XDG_DATA_DIRS="$tmp_path/share''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
|
||||||
|
export fish_complete_path="$tmp_path/share/fish/vendor_completions.d''${fish_complete_path:+:$fish_complete_path}"
|
||||||
|
mkdir -p \
|
||||||
|
$tmp_path/share/fish/vendor_completions.d \
|
||||||
|
$tmp_path/share/bash-completion/completions \
|
||||||
|
$tmp_path/share/zsh/site-functions
|
||||||
|
register-python-argcomplete --shell fish clan > $tmp_path/share/fish/vendor_completions.d/clan.fish
|
||||||
|
register-python-argcomplete --shell bash clan > $tmp_path/share/bash-completion/completions/clan
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user