diff --git a/flake.nix b/flake.nix index 6208616..ff5ba50 100644 --- a/flake.nix +++ b/flake.nix @@ -87,5 +87,13 @@ }; }); + # Templates for starting other projects quickly + templates = { + poetry = { + path = ./templates/poetry; + description = "Poetry template"; + }; + }; + }; } diff --git a/modules/shell/git.nix b/modules/shell/git.nix index 2a14888..823e83a 100644 --- a/modules/shell/git.nix +++ b/modules/shell/git.nix @@ -20,7 +20,6 @@ in { home-manager.users.root.programs.git = { enable = true; extraConfig.safe.directory = config.dotfilesPath; - ignores = [ ".direnv/**" "result" ]; }; home-manager.users.${config.user} = { @@ -34,6 +33,7 @@ in { pull = { ff = "only"; }; init = { defaultBranch = "master"; }; }; + ignores = [ ".direnv/**" "result" ]; }; programs.fish.shellAbbrs = { diff --git a/modules/shell/starship.nix b/modules/shell/starship.nix index f69c343..b6eb972 100644 --- a/modules/shell/starship.nix +++ b/modules/shell/starship.nix @@ -9,7 +9,7 @@ "$git_branch" "$git_commit" "$git_status" - "$python" + "$nix_shell" "$cmd_duration" "$character" ]; @@ -47,7 +47,8 @@ deleted = "✘"; style = "red"; }; - python = { format = "[\\($virtualenv\\)]($style)"; }; + nix_shell = { format = "[$symbol]($style)"; }; + python = { format = "[\${version}\\(\${virtualenv}\\)]($style)"; }; }; }; diff --git a/templates/poetry/.envrc b/templates/poetry/.envrc new file mode 100644 index 0000000..2f707c9 --- /dev/null +++ b/templates/poetry/.envrc @@ -0,0 +1 @@ +use flake . --no-use-registries diff --git a/templates/poetry/.gitignore b/templates/poetry/.gitignore new file mode 100644 index 0000000..21adfa8 --- /dev/null +++ b/templates/poetry/.gitignore @@ -0,0 +1,4 @@ +.direnv +result +*.pyc +.DS_Store diff --git a/templates/poetry/flake.lock b/templates/poetry/flake.lock new file mode 100644 index 0000000..2f87e83 --- /dev/null +++ b/templates/poetry/flake.lock @@ -0,0 +1,92 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1655779787, + "narHash": "sha256-Z5VL2AANN3Rk92xFs/3pPVyDQVTIcmNAIeTQNFOJnNE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ce83dc760cd3428ce9938aa711a0c7c81f55c567", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1655779787, + "narHash": "sha256-Z5VL2AANN3Rk92xFs/3pPVyDQVTIcmNAIeTQNFOJnNE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ce83dc760cd3428ce9938aa711a0c7c81f55c567", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "poetry2nix": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1655482677, + "narHash": "sha256-IGTwio1b4C7Etn4gBb76NILDS+8BsOmDlG8+dhfZL40=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "ea3bd4eb70a3f9ead0dd88dab23e42c542e69c07", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "poetry2nix": "poetry2nix" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/templates/poetry/flake.nix b/templates/poetry/flake.nix new file mode 100644 index 0000000..10f1e5f --- /dev/null +++ b/templates/poetry/flake.nix @@ -0,0 +1,27 @@ +{ + description = "Python project flake"; + + inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs"; + inputs.poetry2nix.url = "github:nix-community/poetry2nix"; + + outputs = { self, nixpkgs, flake-utils, poetry2nix }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ poetry2nix.overlay ]; + }; + projectDir = ./.; + + in { + defaultPackage = + pkgs.poetry2nix.mkPoetryApplication { inherit projectDir; }; + devShells.default = pkgs.mkShell { + buildInputs = [ + (pkgs.poetry2nix.mkPoetryEnv { inherit projectDir; }) + pkgs.poetry + ]; + }; + }); +}