Add poetry2nix
This commit is contained in:
parent
aab2affebc
commit
7b03bd7c68
12
.envrc
12
.envrc
|
@ -5,7 +5,7 @@ layout_postgres() {
|
|||
export PGHOST="$PGDATA"
|
||||
if [[ ! -d "$PGDATA" ]]; then
|
||||
initdb
|
||||
echo -e "listen_addresses = 'localhost'\nunix_socket_directories = '$PGHOST'" >> "$PGDATA/postgresql.conf"
|
||||
echo -e "listen_addresses = 'localhost'\nunix_socket_directories = '$PGHOST'" >>"$PGDATA/postgresql.conf"
|
||||
echo "CREATE DATABASE django;" | postgres --single -E postgres
|
||||
fi
|
||||
}
|
||||
|
@ -22,7 +22,10 @@ layout_poetry() {
|
|||
VIRTUAL_ENV="$(pwd)/.venv"
|
||||
poetry install
|
||||
else
|
||||
VIRTUAL_ENV=$(poetry env info --path 2>/dev/null ; true)
|
||||
VIRTUAL_ENV=$(
|
||||
poetry env info --path 2>/dev/null
|
||||
true
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ -z $VIRTUAL_ENV || ! -d $VIRTUAL_ENV ]]; then
|
||||
|
@ -35,11 +38,12 @@ layout_poetry() {
|
|||
export POETRY_ACTIVE=1
|
||||
export VIRTUAL_ENV
|
||||
}
|
||||
layout poetry
|
||||
if ! has nix; then
|
||||
layout poetry
|
||||
fi
|
||||
export PROJECT_DIR=$(pwd)
|
||||
export WEBPORT=$(($RANDOM + 1100))
|
||||
export PGPORT=$(($WEBPORT + 100))
|
||||
watch_file "$PGDATA/postgresql.conf"
|
||||
watch_file ./dev.sh
|
||||
watch_file ./pyproject.toml
|
||||
|
||||
|
|
79
flake.lock
79
flake.lock
|
@ -18,6 +18,45 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1689068808,
|
||||
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-github-actions": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"poetry2nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1688870561,
|
||||
"narHash": "sha256-4UYkifnPEw1nAzqqPOTL2MvWtm3sNGw1UTYTalkTcGY=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nix-github-actions",
|
||||
"rev": "165b1650b753316aa7f1787f3005a8d2da0f5301",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nix-github-actions",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1690031011,
|
||||
|
@ -34,10 +73,33 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"poetry2nix": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nix-github-actions": "nix-github-actions",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1693051011,
|
||||
"narHash": "sha256-HNbuVCS/Fnl1YZOjBk9/MlIem+wM8fvIzTH0CVQrLSQ=",
|
||||
"owner": "nix-community",
|
||||
"repo": "poetry2nix",
|
||||
"rev": "5b3a5151cf212021ff8d424f215fb030e4ff2837",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "poetry2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"poetry2nix": "poetry2nix"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
|
@ -54,6 +116,21 @@
|
|||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
67
flake.nix
67
flake.nix
|
@ -3,29 +3,50 @@
|
|||
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:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
in
|
||||
rec {
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [
|
||||
pkgs.poetry
|
||||
pkgs.python311
|
||||
pkgs.python311Packages.pip
|
||||
pkgs.overmind
|
||||
pkgs.postgresql_15
|
||||
(pkgs.writeScriptBin "dev" "${builtins.readFile ./dev.sh}")
|
||||
];
|
||||
PYTHON_KEYRING_BACKEND = "keyring.backends.fail.Keyring";
|
||||
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
|
||||
shellHook = ''
|
||||
export DJANGO_SETTINGS_MODULE=htmx_examples.settings
|
||||
'';
|
||||
};
|
||||
}));
|
||||
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
|
||||
{
|
||||
overlays.default = nixpkgs.lib.composeManyExtensions [
|
||||
poetry2nix.overlay
|
||||
(final: prev: rec {
|
||||
htmxDevEnv = prev.poetry2nix.mkPoetryEnv
|
||||
{
|
||||
projectDir = ./.;
|
||||
groups = [ "main" "dev" ];
|
||||
};
|
||||
htmxPackage = prev.poetry2nix.mkPoetryApplication {
|
||||
projectDir = ./.;
|
||||
groups = [ "main" ];
|
||||
};
|
||||
htmxEnv = htmxPackage.dependencyEnv;
|
||||
})
|
||||
];
|
||||
} // (flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ self.overlays.default ];
|
||||
};
|
||||
in
|
||||
rec {
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [
|
||||
pkgs.htmxDevEnv
|
||||
pkgs.poetry
|
||||
pkgs.python311
|
||||
pkgs.python311Packages.pip
|
||||
pkgs.overmind
|
||||
pkgs.postgresql_15
|
||||
(pkgs.writeScriptBin "dev" "${builtins.readFile ./dev.sh}")
|
||||
];
|
||||
shellHook = ''
|
||||
export DJANGO_SETTINGS_MODULE=htmx_examples.settings
|
||||
'';
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ disallow_any_generics = true
|
|||
[tool.django-stubs]
|
||||
django_settings_module = "htmx_examples"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
[tool.poetry.group.main.dependencies]
|
||||
python = "^3.10"
|
||||
django = "^4.2.3"
|
||||
django-htmx = "^1.16.0"
|
||||
|
|
Loading…
Reference in New Issue