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"
}
},
"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": {
"locked": {
"lastModified": 1668765800,
@ -31,10 +46,32 @@
"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": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"poetry2nix": "poetry2nix"
}
}
},

115
flake.nix
View File

@ -3,71 +3,84 @@
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
flake-utils.url = github:numtide/flake-utils;
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
{
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
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlay ];
};
in
{
devShell = pkgs.mkShell {
buildInputs = [
pkgs.gnumake
(pkgs.poetry2nix.mkPoetryEnv {
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.inventory
pkgs.python310Packages.poetry
];
};
shellHook = ''
export DJANGO_SETTINGS_MODULE=network_inventory.settings.local
'';
});
}));
}