Skip to content

Commit e40ed93

Browse files
authored
Merge pull request #1329 from sciyoshi/new-bootstrap-fixes
New bootstrap fixes
2 parents 026032a + 93c345c commit e40ed93

File tree

104 files changed

+7749
-5967
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+7749
-5967
lines changed

.envrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
use nix
1+
use flake
22
watch_file ./nix/*

.github/workflows/ci.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
nix_path: nixpkgs=channel:nixos-unstable
1818
- uses: actions/checkout@v4
1919
- name: Check format
20-
run: nix-shell --packages jq --pure --run 'diff --unified overrides/build-systems.json <(jq --from-file overrides/sort-build-systems.jq --raw-output --sort-keys < overrides/build-systems.json)'
20+
run: nix-shell --packages jq diffutils --run "diff --unified overrides/build-systems.json <(jq --from-file overrides/sort-build-systems.jq --raw-output --sort-keys < overrides/build-systems.json)"
2121

2222
nixpkgs-fmt:
2323
runs-on: ubuntu-latest
@@ -27,7 +27,7 @@ jobs:
2727
nix_path: nixpkgs=channel:nixos-unstable
2828
- uses: actions/checkout@v4
2929
- name: Check format
30-
run: nix-shell --arg packages 'pkgs:[ pkgs.nixpkgs-fmt ]' --run 'nixpkgs-fmt --check .'
30+
run: nix run 'nixpkgs#nixpkgs-fmt' -- --check .
3131

3232
black-fmt:
3333
runs-on: ubuntu-latest
@@ -41,7 +41,7 @@ jobs:
4141
name: poetry2nix
4242
signingKey: "VhaWuN3IyJVpWg+aZvTocVB+W8ziZKKRGLKR53Pkld3YRZxYOUfXZf0fvqF+LkqVW0eA60trVd5vsqNONpX9Hw=="
4343
- name: Check format
44-
run: nix-shell --arg packages 'pkgs:[ pkgs.p2nix-tools.env ]' --run 'black --check .'
44+
run: nix develop -c black --check .
4545

4646
nix-matrix:
4747
runs-on: ubuntu-latest
@@ -60,15 +60,16 @@ jobs:
6060
needs: nix-matrix
6161
runs-on: ${{ matrix.os }}
6262
strategy:
63-
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
63+
fail-fast: false
64+
matrix: ${{ fromJSON(needs.nix-matrix.outputs.matrix) }}
6465
steps:
6566
- uses: actions/checkout@v4
6667
- uses: cachix/install-nix-action@v23
6768
- uses: cachix/cachix-action@v12
6869
with:
6970
name: poetry2nix
7071
signingKey: "VhaWuN3IyJVpWg+aZvTocVB+W8ziZKKRGLKR53Pkld3YRZxYOUfXZf0fvqF+LkqVW0eA60trVd5vsqNONpX9Hw=="
71-
- run: nix build -L ".#${{ matrix.attr }}"
72+
- run: nix build -L ".#${{ matrix.attr }}" --keep-going
7273

7374
collect:
7475
runs-on: ubuntu-latest
@@ -78,4 +79,4 @@ jobs:
7879
- nix-build
7980
- sort-build-systems
8081
steps:
81-
- run: true
82+
- run: exit 0

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ poetry2nix.mkPoetryApplication {
6161
}
6262
```
6363

64-
See [./pkgs/poetry/default.nix](./pkgs/poetry/default.nix) for a working example.
65-
6664
#### Dependency environment
6765

6866
The resulting derivation also has the passthru attribute `dependencyEnv`, which is an environment with a python interpreter, all non-development dependencies and your application.

default.nix

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ lib.makeScope pkgs.newScope (self: {
150150
};
151151
getFunctorFn = fn: if builtins.typeOf fn == "set" then fn.__functor else fn;
152152

153-
poetryPkg = pkgs.callPackage ./pkgs/poetry { inherit python; poetry2nix = self; };
154-
155153
scripts = pyProject.tool.poetry.scripts or { };
156154
hasScripts = scripts != { };
157155
scriptsPackage = self.mkPoetryScriptsPackage {
@@ -251,10 +249,6 @@ lib.makeScope pkgs.newScope (self: {
251249
inherit lib python poetryLib evalPep508;
252250
};
253251

254-
# # Use poetry-core from the poetry build (pep517/518 build-system)
255-
poetry-core = poetryPkg.passthru.python.pkgs.poetry-core;
256-
poetry = poetryPkg;
257-
258252
__toPluginAble = toPluginAble self;
259253
} // lib.optionalAttrs (! super ? setuptools-scm) {
260254
# The canonical name is setuptools-scm

flake.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
22
description = "Poetry2nix flake";
33

4-
inputs.flake-utils.url = "github:numtide/flake-utils";
5-
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
4+
inputs = {
5+
flake-utils.url = "github:numtide/flake-utils";
6+
nixpkgs.url = "github:NixOS/nixpkgs/master";
67

7-
inputs.nix-github-actions.url = "github:nix-community/nix-github-actions";
8-
inputs.nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
8+
nix-github-actions = {
9+
url = "github:nix-community/nix-github-actions";
10+
inputs.nixpkgs.follows = "nixpkgs";
11+
};
12+
};
913

1014
outputs = { self, nixpkgs, flake-utils, nix-github-actions }:
1115
{
@@ -16,7 +20,7 @@
1620
mkPkgs = system: import nixpkgs {
1721
config = {
1822
allowAliases = false;
19-
allowInsecurePredicate = x: true;
23+
allowInsecurePredicate = _: true;
2024
};
2125
overlays = [ self.overlay ];
2226
inherit system;
@@ -40,7 +44,7 @@
4044
# Aggregate all tests into one derivation so that only one GHA runner is scheduled for all darwin jobs
4145
aggregate = pkgs.runCommand "darwin-aggregate"
4246
{
43-
env.TEST_INPUTS = (lib.concatStringsSep " " (lib.attrValues (lib.filterAttrs (n: v: lib.isDerivation v) tests)));
47+
env.TEST_INPUTS = lib.concatStringsSep " " (lib.attrValues (lib.filterAttrs (_: v: lib.isDerivation v) tests));
4448
} "touch $out";
4549
};
4650
};
@@ -53,24 +57,56 @@
5357
};
5458
default = self.templates.app;
5559
};
56-
5760
} // (flake-utils.lib.eachDefaultSystem (system:
5861
let
59-
pkgs = nixpkgs.legacyPackages.${system};
62+
pkgs = import nixpkgs {
63+
inherit system;
64+
overlays = [
65+
(_: _: {
66+
p2nix-tools = pkgs.callPackage ./tools { };
67+
})
68+
];
69+
config = {
70+
allowAliases = false;
71+
permittedInsecurePackages = [
72+
"python3.8-requests-2.29.0"
73+
"python3.8-cryptography-40.0.2"
74+
"python3.9-requests-2.29.0"
75+
"python3.9-cryptography-40.0.2"
76+
"python3.10-requests-2.29.0"
77+
"python3.10-cryptography-40.0.2"
78+
"python3.11-requests-2.29.0"
79+
"python3.11-cryptography-40.0.2"
80+
];
81+
};
82+
};
83+
6084
poetry2nix = import ./default.nix { inherit pkgs; };
61-
poetry = pkgs.callPackage ./pkgs/poetry { python = pkgs.python3; inherit poetry2nix; };
6285
in
6386
rec {
6487
packages = {
65-
inherit poetry;
6688
poetry2nix = poetry2nix.cli;
6789
default = poetry2nix.cli;
6890
};
6991

70-
legacyPackages = poetry2nix;
92+
devShells = {
93+
default = pkgs.mkShell {
94+
nativeBuildInputs = with pkgs; [
95+
p2nix-tools.env
96+
p2nix-tools.flamegraph
97+
nixpkgs-fmt
98+
poetry
99+
niv
100+
jq
101+
nix-prefetch-git
102+
nix-eval-jobs
103+
nix-build-uncached
104+
];
105+
};
106+
};
71107

72108
apps = {
73-
poetry = flake-utils.lib.mkApp { drv = packages.poetry; };
109+
inherit (pkgs) poetry;
74110
poetry2nix = flake-utils.lib.mkApp { drv = packages.poetry2nix; };
75111
default = apps.poetry2nix;
76112
};

hooks/default.nix

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
{ python
2-
, stdenv
3-
, buildPackages
4-
, makeSetupHook
5-
, wheel
6-
, pip
7-
, pkgs
8-
, lib
9-
,
10-
}:
1+
{ python, stdenv, makeSetupHook, pkgs, lib }:
112
let
12-
inherit (python.pythonForBuild.pkgs) callPackage;
13-
pythonInterpreter = python.pythonForBuild.interpreter;
3+
inherit (python) pythonForBuild;
4+
inherit (pythonForBuild.pkgs) callPackage;
5+
pythonInterpreter = pythonForBuild.interpreter;
146
pythonSitePackages = python.sitePackages;
157

168
nonOverlayedPython = pkgs.python3.pythonForBuild.withPackages (ps: [ ps.tomlkit ]);
17-
makeRemoveSpecialDependenciesHook =
18-
{ fields
19-
, kind
20-
,
21-
}:
9+
makeRemoveSpecialDependenciesHook = { fields, kind }:
2210
nonOverlayedPython.pkgs.callPackage
2311
(
2412
_:
@@ -57,10 +45,7 @@ in
5745
pipBuildHook =
5846
callPackage
5947
(
60-
{ pip
61-
, wheel
62-
,
63-
}:
48+
{ pip, wheel }:
6449
makeSetupHook
6550
({
6651
name = "pip-build-hook.sh";
@@ -118,9 +103,7 @@ in
118103
'';
119104
};
120105

121-
pythonPath =
122-
[ ]
123-
++ lib.optional (lib.versionOlder python.version "3.9") unparser;
106+
pythonPath = lib.optional (lib.versionOlder python.version "3.9") unparser;
124107
in
125108
makeSetupHook
126109
{
@@ -133,18 +116,4 @@ in
133116
./python-requires-patch-hook.sh
134117
)
135118
{ };
136-
137-
# When the "wheel" package itself is a wheel the nixpkgs hook (which pulls in "wheel") leads to infinite recursion
138-
# It doesn't _really_ depend on wheel though, it just copies the wheel.
139-
wheelUnpackHook =
140-
callPackage
141-
(
142-
_:
143-
makeSetupHook
144-
{
145-
name = "wheel-unpack-hook.sh";
146-
}
147-
./wheel-unpack-hook.sh
148-
)
149-
{ };
150119
}

hooks/pip-build-hook.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
# Setup hook to use for pip projects
22
echo "Sourcing pip-build-hook"
33

4+
declare -a pipBuildFlags
5+
46
pipBuildPhase() {
57
echo "Executing pipBuildPhase"
68
runHook preBuild
79

810
mkdir -p dist
911
echo "Creating a wheel..."
10-
@pythonInterpreter@ -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist .
12+
@pythonInterpreter@ -m pip wheel \
13+
--verbose \
14+
--no-index \
15+
--no-deps \
16+
--no-clean \
17+
--no-build-isolation \
18+
--wheel-dir dist \
19+
$pipBuildFlags .
1120
echo "Finished creating a wheel..."
1221

1322
runHook postBuild
@@ -24,7 +33,8 @@ pipShellHook() {
2433
export PATH="$tmp_path/bin:$PATH"
2534
export PYTHONPATH="$tmp_path/@pythonSitePackages@:$PYTHONPATH"
2635
mkdir -p "$tmp_path/@pythonSitePackages@"
27-
@pythonInterpreter@ -m pip install -e . --prefix "$tmp_path" >&2
36+
@pythonInterpreter@ -m pip install -e . --prefix "$tmp_path" \
37+
--no-build-isolation >&2
2838
fi
2939

3040
runHook postShellHook

known-build-systems.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
[
2-
"poetry",
3-
"poetry-core",
4-
"flit",
5-
"flit-core",
6-
"pbr",
7-
"flitBuildHook",
8-
"cython",
9-
"hatchling",
10-
"hatch-vcs",
11-
"setuptools",
12-
"setuptools-scm"
2+
"poetry",
3+
"poetry-core",
4+
"flit",
5+
"flit-core",
6+
"pbr",
7+
"cython",
8+
"hatchling",
9+
"hatch-vcs",
10+
"setuptools",
11+
"setuptools-scm"
1312
]

0 commit comments

Comments
 (0)