From 4d5e06667b32e1c06add53cf14c0e84a85107c7a Mon Sep 17 00:00:00 2001 From: pegasust Date: Fri, 30 Dec 2022 07:14:33 -0700 Subject: [PATCH 1/5] commented code is deadcode - the fix --- nix-conf/home-manager/base/keepass.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nix-conf/home-manager/base/keepass.nix b/nix-conf/home-manager/base/keepass.nix index b845f58..84f6ca3 100644 --- a/nix-conf/home-manager/base/keepass.nix +++ b/nix-conf/home-manager/base/keepass.nix @@ -56,9 +56,5 @@ in KEEPASSDB_TIMEOUT = cfg.copy_timeout_secs; }; }); - # xdg.dataFile."keepass.kdbx".path = - # base.shells.shellAliases = { - # kp = "kpcli --kdb=${cfg.path}"; - # }; }; } From 7000b86d387640a53e3a678a00062069ace127a6 Mon Sep 17 00:00:00 2001 From: pegasust Date: Sat, 31 Dec 2022 01:40:26 -0700 Subject: [PATCH 2/5] framework on devShells? --- nix-conf/home-manager/base/neovim.nix | 5 +++ templates/default.nix | 4 ++ templates/ts/turborepo/flake.nix | 53 +++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 templates/ts/turborepo/flake.nix diff --git a/nix-conf/home-manager/base/neovim.nix b/nix-conf/home-manager/base/neovim.nix index f1e51c5..29d6841 100644 --- a/nix-conf/home-manager/base/neovim.nix +++ b/nix-conf/home-manager/base/neovim.nix @@ -77,6 +77,11 @@ in vimAlias = true; withPython3 = true; withNodeJs = true; + # Attempt 4: Correct way to make neovim aware of packages + # homeConfigurations.config.programs.neovim takes UNWRAPPED neovim + # and wraps it. + # Ideally, we build our own neovim and add that to config.home.packages + # to share it with nixOS. But we don't really need to share extraPackages = nvim_pkgs; # only for here for archive-documentation # extraPython3Packages = (pypkgs: [ diff --git a/templates/default.nix b/templates/default.nix index 041b23b..70d9fe4 100644 --- a/templates/default.nix +++ b/templates/default.nix @@ -12,4 +12,8 @@ path = ./rust-monorepo; description = "Opinionated Rust monorepo, extended from ./rust, using Cargo workspace"; }; + ts-turborepo = { + path = ./ts/turborepo; + description = "Typescript monorepo with tsconfig, eslint, but with minimal framework attached"; + }; } diff --git a/templates/ts/turborepo/flake.nix b/templates/ts/turborepo/flake.nix new file mode 100644 index 0000000..8446117 --- /dev/null +++ b/templates/ts/turborepo/flake.nix @@ -0,0 +1,53 @@ +{ + description = "Provides devShell for Nodejs + pnpm"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + # https://github.com/vercel/turbo/issues/2293#issuecomment-1296094236 + # work-around for turbo-repo on nix + turbo.url = "github:dlip/turbo"; + }; + + outputs = { self, turbo, flake-utils, nixpkgs }: + with flake-utils; lib.eachSystem lib.defaultSystems (sys: + let + overlays = [ turbo.overlay ]; + # pkgs is our tweaked nixpkgs + pkgs = import nixpkgs { system = sys; overlays = overlays; }; + shellMsg = '' + echo "Hello from nix ${sys}" + echo "Local development may use our remote planetscale database (pscale login && pnpm dev:infra; pnpm dev)" + echo "Or from the specified docker-compose.yml (pnpm dev:local_infra && pnpm dev)" + echo "See more on CONTRIBUTING.md" + ''; + in + { + devShell = pkgs.mkShell { + nativeBuildInputs = [ pkgs.bashInteractive ]; + buildInputs = [ + pkgs.nodejs-18_x + pkgs.nodePackages.pnpm + pkgs.nodePackages.prisma + pkgs.prisma-engines + pkgs.turbo + # pkgs.turbo-tooling + pkgs.jq + pkgs.pscale + pkgs.act # Github workflow + ]; + shellHook = + # https://github.com/prisma/prisma/issues/3026#issuecomment-927258138 + # nix-direnv is required (impure build?) https://github.com/nix-community/nix-direnv + '' + export PRISMA_MIGRATION_ENGINE_BINARY="${pkgs.prisma-engines}/bin/migration-engine" + export PRISMA_QUERY_ENGINE_BINARY="${pkgs.prisma-engines}/bin/query-engine" + export PRISMA_QUERY_ENGINE_LIBRARY="${pkgs.prisma-engines}/lib/libquery_engine.node" + export PRISMA_INTROSPECTION_ENGINE_BINARY="${pkgs.prisma-engines}/bin/introspection-engine" + export PRISMA_FMT_BINARY="${pkgs.prisma-engines}/bin/prisma-fmt" + export TURBO_BINARY_PATH="${pkgs.turbo}/bin/turbo" + pnpm install + '' + shellMsg; + }; + }); +} From 2b4b2a901f29e6662425fb3ad68088fe363f8ac2 Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 2 Jan 2023 22:48:12 -0700 Subject: [PATCH 3/5] hm-switch should now updates neovim and some of its plugins --- flake.lock | 18 +++++++++--------- nix-conf/home-manager/flake.lock | 22 +++++++++++----------- scripts/hm-switch.sh | 3 +++ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index ec98f01..2941a1f 100644 --- a/flake.lock +++ b/flake.lock @@ -89,11 +89,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1672349765, - "narHash": "sha256-Ul3lSGglgHXhgU3YNqsNeTlRH1pqxbR64h+2hM+HtnM=", + "lastModified": 1672688183, + "narHash": "sha256-3sNEWKTg3XXVDnvzVatdyetiUQWL+ibJ1YkvxSk3PuM=", "owner": "nix-community", "repo": "home-manager", - "rev": "dd99675ee81fef051809bc87d67eb07f5ba022e8", + "rev": "c1a830c8fabb13f95f51ecf48552f0a794d8718a", "type": "github" }, "original": { @@ -154,11 +154,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1672262501, - "narHash": "sha256-ZNXqX9lwYo1tOFAqrVtKTLcJ2QMKCr3WuIvpN8emp7I=", + "lastModified": 1672525397, + "narHash": "sha256-WASDnyxHKWVrEe0dIzkpH+jzKlCKAk0husv0f/9pyxg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e182da8622a354d44c39b3d7a542dc12cd7baa5f", + "rev": "8ba56d7c0d7490680f2d51ba46a141eca7c46afa", "type": "github" }, "original": { @@ -201,11 +201,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1672367043, - "narHash": "sha256-4/40kfJysfDEfSpXJ3inuMetn40czz5Mh73SjxsKTX0=", + "lastModified": 1672712534, + "narHash": "sha256-8S0DdMPcbITnlOu0uA81mTo3hgX84wK8S9wS34HEFY4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "e6b2214363f5e18576a3b2ca0e0483d8f42fe531", + "rev": "69fb7bf0a8c40e6c4c197fa1816773774c8ac59f", "type": "github" }, "original": { diff --git a/nix-conf/home-manager/flake.lock b/nix-conf/home-manager/flake.lock index 6465d36..06e96d9 100644 --- a/nix-conf/home-manager/flake.lock +++ b/nix-conf/home-manager/flake.lock @@ -69,11 +69,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1672349765, - "narHash": "sha256-Ul3lSGglgHXhgU3YNqsNeTlRH1pqxbR64h+2hM+HtnM=", + "lastModified": 1672688183, + "narHash": "sha256-3sNEWKTg3XXVDnvzVatdyetiUQWL+ibJ1YkvxSk3PuM=", "owner": "nix-community", "repo": "home-manager", - "rev": "dd99675ee81fef051809bc87d67eb07f5ba022e8", + "rev": "c1a830c8fabb13f95f51ecf48552f0a794d8718a", "type": "github" }, "original": { @@ -106,11 +106,11 @@ "locked": { "lastModified": 1, "narHash": "sha256-KP+2qdZlhmRkrafuuEofg7YnNdVmGV95ipvpuqmJneI=", - "path": "/nix/store/qcm4676fqkcdrizjkn4j0796ybddwlxm-source/out-of-tree/nixGL", + "path": "/nix/store/zcawhhz89smqvmyqp985cmlsh6y81789-source/out-of-tree/nixGL", "type": "path" }, "original": { - "path": "/nix/store/qcm4676fqkcdrizjkn4j0796ybddwlxm-source/out-of-tree/nixGL", + "path": "/nix/store/zcawhhz89smqvmyqp985cmlsh6y81789-source/out-of-tree/nixGL", "type": "path" } }, @@ -131,11 +131,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1672262501, - "narHash": "sha256-ZNXqX9lwYo1tOFAqrVtKTLcJ2QMKCr3WuIvpN8emp7I=", + "lastModified": 1672525397, + "narHash": "sha256-WASDnyxHKWVrEe0dIzkpH+jzKlCKAk0husv0f/9pyxg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e182da8622a354d44c39b3d7a542dc12cd7baa5f", + "rev": "8ba56d7c0d7490680f2d51ba46a141eca7c46afa", "type": "github" }, "original": { @@ -178,11 +178,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1672367043, - "narHash": "sha256-4/40kfJysfDEfSpXJ3inuMetn40czz5Mh73SjxsKTX0=", + "lastModified": 1672712534, + "narHash": "sha256-8S0DdMPcbITnlOu0uA81mTo3hgX84wK8S9wS34HEFY4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "e6b2214363f5e18576a3b2ca0e0483d8f42fe531", + "rev": "69fb7bf0a8c40e6c4c197fa1816773774c8ac59f", "type": "github" }, "original": { diff --git a/scripts/hm-switch.sh b/scripts/hm-switch.sh index 6ff6f5b..9477978 100755 --- a/scripts/hm-switch.sh +++ b/scripts/hm-switch.sh @@ -7,6 +7,9 @@ echo "SCRIPT_DIR: ${SCRIPT_DIR}" HOME_MANAGER_DIR="${SCRIPT_DIR}/../nix-conf/home-manager" +# Mason is bad: it puts binaries onto xdg.data +rm -rf ~/.local/share/nvim/mason + # test if we have home-manager, if not, attempt to use nix to put home-manager to # our environment if [ $(home-manager >/dev/null 2>&1) ]; then From 077eba7ec03b609959d77b38990b03c6f657562e Mon Sep 17 00:00:00 2001 From: pegasust Date: Tue, 3 Jan 2023 13:10:04 -0700 Subject: [PATCH 4/5] relative flake done right --- flake.lock | 27 ++++++++++++--------------- flake.nix | 2 +- nix-conf/home-manager/flake.lock | 16 ++++++++-------- nix-conf/home-manager/flake.nix | 2 +- nix-conf/system/flake.lock | 6 +++--- 5 files changed, 25 insertions(+), 28 deletions(-) diff --git a/flake.lock b/flake.lock index 2941a1f..6b10ce5 100644 --- a/flake.lock +++ b/flake.lock @@ -89,11 +89,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1672688183, - "narHash": "sha256-3sNEWKTg3XXVDnvzVatdyetiUQWL+ibJ1YkvxSk3PuM=", + "lastModified": 1672770368, + "narHash": "sha256-iO6Z9blIe8dcPh3VT2nkej9EimORCoskGQR6xNjICWI=", "owner": "nix-community", "repo": "home-manager", - "rev": "c1a830c8fabb13f95f51ecf48552f0a794d8718a", + "rev": "d01e7280ad7d13a5a0fae57355bd0dbfe5b81969", "type": "github" }, "original": { @@ -124,17 +124,14 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1661367362, - "narHash": "sha256-Qc8MXcV+YCPREu8kk6oggk23ZBKLqeQRAIsLbHEviPE=", - "owner": "guibou", - "repo": "nixGL", - "rev": "7165ffbccbd2cf4379b6cd6d2edd1620a427e5ae", - "type": "github" + "lastModified": 1, + "narHash": "sha256-KP+2qdZlhmRkrafuuEofg7YnNdVmGV95ipvpuqmJneI=", + "path": "out-of-tree/nixGL", + "type": "path" }, "original": { - "owner": "guibou", - "repo": "nixGL", - "type": "github" + "path": "out-of-tree/nixGL", + "type": "path" } }, "nixpkgs": { @@ -154,11 +151,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1672525397, - "narHash": "sha256-WASDnyxHKWVrEe0dIzkpH+jzKlCKAk0husv0f/9pyxg=", + "lastModified": 1672617983, + "narHash": "sha256-68WDiCBs631mbDDk4UAKdGURKcsfW6hjb7wgudTAe5o=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8ba56d7c0d7490680f2d51ba46a141eca7c46afa", + "rev": "0fc9fca9c8d43edd79d33fea0dd8409d7c4580f4", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 6091d69..efd1cd2 100644 --- a/flake.nix +++ b/flake.nix @@ -11,7 +11,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; flake-utils.url = "github:numtide/flake-utils"; - nixgl.url = "github:guibou/nixGL"; + nixgl.url = "path:out-of-tree/nixGL"; rust-overlay.url = "github:oxalica/rust-overlay"; # Allows default.nix to call onto flake.nix. Useful for nix eval and automations flake-compat = { diff --git a/nix-conf/home-manager/flake.lock b/nix-conf/home-manager/flake.lock index 06e96d9..16cae97 100644 --- a/nix-conf/home-manager/flake.lock +++ b/nix-conf/home-manager/flake.lock @@ -69,11 +69,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1672688183, - "narHash": "sha256-3sNEWKTg3XXVDnvzVatdyetiUQWL+ibJ1YkvxSk3PuM=", + "lastModified": 1672770368, + "narHash": "sha256-iO6Z9blIe8dcPh3VT2nkej9EimORCoskGQR6xNjICWI=", "owner": "nix-community", "repo": "home-manager", - "rev": "c1a830c8fabb13f95f51ecf48552f0a794d8718a", + "rev": "d01e7280ad7d13a5a0fae57355bd0dbfe5b81969", "type": "github" }, "original": { @@ -106,11 +106,11 @@ "locked": { "lastModified": 1, "narHash": "sha256-KP+2qdZlhmRkrafuuEofg7YnNdVmGV95ipvpuqmJneI=", - "path": "/nix/store/zcawhhz89smqvmyqp985cmlsh6y81789-source/out-of-tree/nixGL", + "path": "./../../out-of-tree/nixGL", "type": "path" }, "original": { - "path": "/nix/store/zcawhhz89smqvmyqp985cmlsh6y81789-source/out-of-tree/nixGL", + "path": "./../../out-of-tree/nixGL", "type": "path" } }, @@ -131,11 +131,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1672525397, - "narHash": "sha256-WASDnyxHKWVrEe0dIzkpH+jzKlCKAk0husv0f/9pyxg=", + "lastModified": 1672617983, + "narHash": "sha256-68WDiCBs631mbDDk4UAKdGURKcsfW6hjb7wgudTAe5o=", "owner": "nixos", "repo": "nixpkgs", - "rev": "8ba56d7c0d7490680f2d51ba46a141eca7c46afa", + "rev": "0fc9fca9c8d43edd79d33fea0dd8409d7c4580f4", "type": "github" }, "original": { diff --git a/nix-conf/home-manager/flake.nix b/nix-conf/home-manager/flake.nix index a6ac1e5..2eb9188 100644 --- a/nix-conf/home-manager/flake.nix +++ b/nix-conf/home-manager/flake.nix @@ -7,7 +7,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; flake-utils.url = "github:numtide/flake-utils"; - nixgl.url = "./../../out-of-tree/nixGL"; + nixgl.url = "path:./../../out-of-tree/nixGL"; rust-overlay.url = "github:oxalica/rust-overlay"; # Allows default.nix to call onto flake.nix. Useful for nix eval and automations flake-compat = { diff --git a/nix-conf/system/flake.lock b/nix-conf/system/flake.lock index 64f2e8c..2761459 100644 --- a/nix-conf/system/flake.lock +++ b/nix-conf/system/flake.lock @@ -22,11 +22,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1671359686, - "narHash": "sha256-3MpC6yZo+Xn9cPordGz2/ii6IJpP2n8LE8e/ebUXLrs=", + "lastModified": 1672525397, + "narHash": "sha256-WASDnyxHKWVrEe0dIzkpH+jzKlCKAk0husv0f/9pyxg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "04f574a1c0fde90b51bf68198e2297ca4e7cccf4", + "rev": "8ba56d7c0d7490680f2d51ba46a141eca7c46afa", "type": "github" }, "original": { From bd62ef48c2aaba62a34e5e06e20a79a192482c6f Mon Sep 17 00:00:00 2001 From: pegasust Date: Tue, 3 Jan 2023 15:34:51 -0700 Subject: [PATCH 5/5] rust-monorepo: rust-analyzer fresh from rustup --- nix-conf/home-manager/base/neovim.nix | 9 ++++++--- templates/rust-monorepo/flake.nix | 18 ++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/nix-conf/home-manager/base/neovim.nix b/nix-conf/home-manager/base/neovim.nix index 29d6841..dc3f0be 100644 --- a/nix-conf/home-manager/base/neovim.nix +++ b/nix-conf/home-manager/base/neovim.nix @@ -47,9 +47,12 @@ let # Language-specific stuffs pkgs.sumneko-lua-language-server - pkgs.rust-analyzer - rust_pkgs - pkgs.evcxr # Rust REPL for Conjure! + # TODO: the devShell should provide rust-analyzer so that + # cargo test builds binaries compatible with rust-analyzer + + # pkgs.rust-analyzer + # rust_pkgs + # pkgs.evcxr # Rust REPL for Conjure! # Python3 as alternative to bash scripts :^) # (pkgs.python310Full.withPackages (pypkgs: [ diff --git a/templates/rust-monorepo/flake.nix b/templates/rust-monorepo/flake.nix index bb75c40..f352b18 100644 --- a/templates/rust-monorepo/flake.nix +++ b/templates/rust-monorepo/flake.nix @@ -11,23 +11,21 @@ let overlays = [ rust-overlay.overlays.default ]; pkgs = import nixpkgs { inherit system overlays; }; + rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith + ( + toolchain: + toolchain.default.override { + extensions = [ "rust-src" "rust-analyzer" "rust-docs" "clippy" "miri" ]; + } + )); naersk-lib = pkgs.callPackage naersk { }; in { defaultPackage = naersk-lib.buildPackage ./.; devShell = with pkgs; mkShell { buildInputs = [ - (pkgs.rust-bin.selectLatestNightlyWith - ( - toolchain: - toolchain.default.override { - extensions = [ "rust-src" ]; - } - )) - pkgs.rust-analyzer - pkgs.bacon # rust background code checker + rust_pkgs ]; - RUST_SRC_PATH = rustPlatform.rustLibSrc; shellHook = '' # nix flake update # is this even needed? '';