Skip to content

Commit

Permalink
Migrate from Niv to Flakes
Browse files Browse the repository at this point in the history
It's annoying to have two incompatible version managers.
  • Loading branch information
adisbladis committed Jul 14, 2023
1 parent 406b840 commit 96d87dc
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 184 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
name: Generate Nix Matrix
run: |
set -Eeu
echo "matrix=$(nix eval --json -f ./.github/ci.nix matrix)" >> "$GITHUB_OUTPUT"
echo "matrix=$(nix eval --json '.#githubActions.matrix')" >> "$GITHUB_OUTPUT"
nix-build:
needs: nix-matrix
Expand All @@ -68,7 +68,7 @@ jobs:
with:
name: poetry2nix
signingKey: "VhaWuN3IyJVpWg+aZvTocVB+W8ziZKKRGLKR53Pkld3YRZxYOUfXZf0fvqF+LkqVW0eA60trVd5vsqNONpX9Hw=="
- run: nix-build --keep-going --show-trace .github/ci.nix -A '${{ matrix.attr }}'
- run: nix build -L ".#${{ matrix.attr }}"

collect:
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ result*
artifacts
poetry2nix-flamegraph.svg
.direnv
flake.lock

.idea/
82 changes: 82 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 40 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,50 @@
description = "Poetry2nix flake";

inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/45dc78cb0a93fc84eaa1fea85bda28865eab1a44";

outputs = { self, nixpkgs, flake-utils }:
inputs.nix-github-actions.url = "github:nix-community/nix-github-actions";
inputs.nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";

outputs = { self, nixpkgs, flake-utils, nix-github-actions }:
{
overlay = import ./overlay.nix;

githubActions =
let
mkPkgs = system: import nixpkgs {
config = {
allowAliases = false;
allowInsecurePredicate = x: true;
};
overlays = [ self.overlay ];
inherit system;
};
in
nix-github-actions.lib.mkGithubMatrix {
checks = {
x86_64-linux =
let
pkgs = mkPkgs "x86_64-linux";
in
import ./tests { inherit pkgs; };

x86_64-darwin =
let
pkgs = mkPkgs "x86_64-darwin";
inherit (pkgs) lib;
tests = import ./tests { inherit pkgs; };
in
{
# Aggregate all tests into one derivation so that only one GHA runner is scheduled for all darwin jobs
aggregate = pkgs.runCommand "darwin-aggregate"
{
env.TEST_INPUTS = (lib.concatStringsSep " " (lib.attrValues (lib.filterAttrs (n: v: lib.isDerivation v) tests)));
} "touch $out";
};
};
};

templates = {
app = {
path = ./templates/app;
Expand Down
26 changes: 0 additions & 26 deletions nix/sources.json

This file was deleted.

131 changes: 0 additions & 131 deletions nix/sources.nix

This file was deleted.

9 changes: 5 additions & 4 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
}:

let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {
flake = builtins.getFlake "${toString ./.}";

pkgs = import flake.inputs.nixpkgs {
overlays = [
(import ./overlay.nix)
flake.overlay
(self: super: {
p2nix-tools = self.callPackage ./tools { };
})
Expand All @@ -24,6 +25,6 @@ let

in
pkgs.mkShell {
NIX_PATH = "nixpkgs=${sources.nixpkgs}";
NIX_PATH = "nixpkgs=${flake.inputs.nixpkgs}";
packages = packages pkgs;
}
13 changes: 6 additions & 7 deletions tests/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
let
sources = import ../nix/sources.nix;
flake = builtins.getFlake "${toString ../.}";
in
{ pkgs ? import sources.nixpkgs {
{ pkgs ? import flake.inputs.nixpkgs {
config = {
allowAliases = false;
allowInsecurePredicate = x: true;
};
overlays = [
(import ../overlay.nix)
];
overlays = [ flake.overlay ];
}
}:
let
Expand All @@ -35,7 +33,7 @@ in
override-default = callTest ./override-default-support { };
common-pkgs-1 = callTest ./common-pkgs-1 { };
common-pkgs-2 = callTest ./common-pkgs-2 { };
pep425 = pkgs.callPackage ./pep425 { inherit pep425; inherit pep425OSX; inherit pep425PythonOldest; };
# pep425 = pkgs.callPackage ./pep425 { inherit pep425; inherit pep425OSX; inherit pep425PythonOldest; };
env = callTest ./env { };
pytest-metadata = callTest ./pytest-metadata { };
pytest-randomly = callTest ./pytest-randomly { };
Expand All @@ -47,7 +45,6 @@ in
git-deps-1_2_0 = callTest ./git-deps-1_2_0 { };
git-deps-pinned = callTest ./git-deps-pinned { };
in-list = callTest ./in-list { };
cli = poetry2nix;
path-deps = callTest ./path-deps { };
path-deps-develop = callTest ./path-deps-develop { };
path-deps-level2 = callTest ./path-deps-level2 { };
Expand All @@ -64,6 +61,8 @@ in
wandb = callTest ./wandb { };
utf8-pyproject = callTest ./utf8-pyproject { };

inherit (poetry2nix) cli;

ansible-molecule = callTest ./ansible-molecule { };
bcrypt = callTest ./bcrypt { };
mk-poetry-packages = callTest ./mk-poetry-packages { };
Expand Down
2 changes: 1 addition & 1 deletion tests/mk-poetry-packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ let
in
assert builtins.elem "certifi" packageNamesCurrent;
assert builtins.elem "certifi" packageNamesPythonOldest;
drvPythonCurrent
drvPythonCurrent.python
Loading

0 comments on commit 96d87dc

Please sign in to comment.