Use poetry2nix as a flake

This commit is contained in:
Andreas Zweili 2022-11-19 19:17:13 +01:00
parent 6b1145956e
commit 26c0cc4990
2 changed files with 102 additions and 52 deletions

View File

@ -15,6 +15,21 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1668765800, "lastModified": 1668765800,
@ -31,10 +46,32 @@
"type": "github" "type": "github"
} }
}, },
"poetry2nix": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1668738526,
"narHash": "sha256-OtyHtZalpeTjZ5B44C8wV3WqTUmeBBxoGc7KPIkwxAU=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "0c5bae34bee822876a2dbb1c62d89cd1b29b648d",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "poetry2nix",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs",
"poetry2nix": "poetry2nix"
} }
} }
}, },

115
flake.nix
View File

@ -3,71 +3,84 @@
inputs = { inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable; nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
flake-utils.url = github:numtide/flake-utils; flake-utils.url = github:numtide/flake-utils;
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = { self, nixpkgs, flake-utils }: outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system: {
overlay = nixpkgs.lib.composeManyExtensions [
poetry2nix.overlay
(final: prev: {
inventory = prev.poetry2nix.mkPoetryEnv {
projectDir = ./.;
overrides = prev.poetry2nix.defaultPoetryOverrides.extend
(self: super: {
findpython = super.findpython.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.pdm ];
}
);
django-floppyforms =
super.django-floppyforms.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
}
);
django-crispy-forms = super.django-crispy-forms.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
}
);
django-nested-admin = super.django-crispy-forms.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
}
);
exceptiongroup = super.exceptiongroup.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.flit-scm ];
}
);
python-monkey-business = super.python-monkey-business.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.flit-scm ];
}
);
pytoolconfig = super.pytoolconfig.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.pdm ];
}
);
});
};
})
];
} // (flake-utils.lib.eachDefaultSystem (system:
let let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [ self.overlay ];
}; };
in in
{ {
devShell = pkgs.mkShell { devShell = pkgs.mkShell {
buildInputs = [ buildInputs = [
pkgs.gnumake pkgs.gnumake
(pkgs.poetry2nix.mkPoetryEnv { pkgs.inventory
projectDir = ./.;
overrides = pkgs.poetry2nix.defaultPoetryOverrides.extend
(self: super: {
findpython = super.findpython.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.pdm ];
}
);
django-floppyforms =
super.django-floppyforms.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
}
);
django-crispy-forms = super.django-crispy-forms.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
}
);
django-nested-admin = super.django-crispy-forms.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
}
);
exceptiongroup = super.exceptiongroup.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.flit-scm ];
}
);
python-monkey-business = super.python-monkey-business.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.flit-scm ];
}
);
pytoolconfig = super.pytoolconfig.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.pdm ];
}
);
});
})
pkgs.python310Packages.poetry pkgs.python310Packages.poetry
]; ];
}; };
shellHook = '' shellHook = ''
export DJANGO_SETTINGS_MODULE=network_inventory.settings.local export DJANGO_SETTINGS_MODULE=network_inventory.settings.local
''; '';
}); }));
} }