From 93b802ae0137ea02bdc0381fa3f0296baee39100 Mon Sep 17 00:00:00 2001 From: aemogie <54412618+aemogie@users.noreply.github.com> Date: Thu, 2 May 2024 13:35:49 +0530 Subject: [PATCH 1/7] feat(direnv): init --- direnv/.envrc | 1 + direnv/flake.nix | 15 +++++++++++++++ flake.nix | 4 ++++ 3 files changed, 20 insertions(+) create mode 100644 direnv/.envrc create mode 100644 direnv/flake.nix diff --git a/direnv/.envrc b/direnv/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/direnv/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/direnv/flake.nix b/direnv/flake.nix new file mode 100644 index 0000000..91cc9b6 --- /dev/null +++ b/direnv/flake.nix @@ -0,0 +1,15 @@ +{ + description = "An empty devshell with direnv support"; + + inputs.nixpkgs.url = "github:auxolotl/nixpkgs/nixpkgs-unstable"; + + outputs = + { nixpkgs, ... }: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in + { + devShells.${system}.default = pkgs.mkShell { packages = [ pkgs.hello ]; }; + }; +} diff --git a/flake.nix b/flake.nix index 574347b..647bf2c 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,10 @@ path = ./darwin; description = ""; }; + direnv = { + path = ./direnv; + description = "An empty devshell with direnv support"; + }; }; formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style); }; From d181eb421a461e4cac657679124cb6c7eb0bb0b2 Mon Sep 17 00:00:00 2001 From: aemogie <54412618+aemogie@users.noreply.github.com> Date: Fri, 3 May 2024 11:34:11 +0530 Subject: [PATCH 2/7] chore(direnv): only use flake if nix(-direnv) is installed Co-authored-by: seth --- direnv/.envrc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/direnv/.envrc b/direnv/.envrc index 8392d15..c702436 100644 --- a/direnv/.envrc +++ b/direnv/.envrc @@ -1 +1,3 @@ -use flake \ No newline at end of file +if has nix_direnv_version; then + use flake +fi \ No newline at end of file From a1f552138316d902c3aea46a07d7158ba1244879 Mon Sep 17 00:00:00 2001 From: aemogie <54412618+aemogie@users.noreply.github.com> Date: Fri, 3 May 2024 11:38:32 +0530 Subject: [PATCH 3/7] feat(direnv): forAllSystems --- direnv/flake.nix | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/direnv/flake.nix b/direnv/flake.nix index 91cc9b6..f35050a 100644 --- a/direnv/flake.nix +++ b/direnv/flake.nix @@ -6,10 +6,18 @@ outputs = { nixpkgs, ... }: let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; + forAllSystems = + function: + nixpkgs.lib.genAttrs [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ] (system: function nixpkgs.legacyPackages.${system}); in { - devShells.${system}.default = pkgs.mkShell { packages = [ pkgs.hello ]; }; + devShells = forAllSystems (pkgs: { + default = pkgs.mkShell { packages = [ pkgs.hello ]; }; + }); }; } From 8637edba9b15c086219afbeb7c76d29912c6b5fa Mon Sep 17 00:00:00 2001 From: aemogie <54412618+aemogie@users.noreply.github.com> Date: Fri, 3 May 2024 11:39:43 +0530 Subject: [PATCH 4/7] feat(direnv): example env var --- direnv/flake.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/direnv/flake.nix b/direnv/flake.nix index f35050a..2c171d1 100644 --- a/direnv/flake.nix +++ b/direnv/flake.nix @@ -17,7 +17,10 @@ in { devShells = forAllSystems (pkgs: { - default = pkgs.mkShell { packages = [ pkgs.hello ]; }; + default = pkgs.mkShell { + packages = [ pkgs.hello ]; + IN_SHELL = "yes!"; + }; }); }; } From 0d02eb962d7707294d0ac72cbb1a9ace114d30ab Mon Sep 17 00:00:00 2001 From: aemogie <54412618+aemogie@users.noreply.github.com> Date: Fri, 3 May 2024 12:04:06 +0530 Subject: [PATCH 5/7] feat(direnv): prefer mkShellNoCC --- direnv/flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/direnv/flake.nix b/direnv/flake.nix index 2c171d1..7b5b8d9 100644 --- a/direnv/flake.nix +++ b/direnv/flake.nix @@ -17,7 +17,7 @@ in { devShells = forAllSystems (pkgs: { - default = pkgs.mkShell { + default = pkgs.mkShellNoCC { packages = [ pkgs.hello ]; IN_SHELL = "yes!"; }; From 97ddb19f9e1f84710b8edeb8f58a76242d253e88 Mon Sep 17 00:00:00 2001 From: aemogie <54412618+aemogie@users.noreply.github.com> Date: Fri, 3 May 2024 17:39:51 +0530 Subject: [PATCH 6/7] feat(direnv): add shellhook, rename env var --- direnv/flake.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/direnv/flake.nix b/direnv/flake.nix index 7b5b8d9..1df77ea 100644 --- a/direnv/flake.nix +++ b/direnv/flake.nix @@ -19,7 +19,10 @@ devShells = forAllSystems (pkgs: { default = pkgs.mkShellNoCC { packages = [ pkgs.hello ]; - IN_SHELL = "yes!"; + EXAMPLE_VAR = "inside the direnv template"; + shellHook = '' + echo "Hello from $EXAMPLE_VAR, $(whoami)!" + ''; }; }); }; From 39dbc968982b7722627b8ae5a23ed0ff485ba304 Mon Sep 17 00:00:00 2001 From: aemogie <54412618+aemogie@users.noreply.github.com> Date: Fri, 3 May 2024 18:06:43 +0530 Subject: [PATCH 7/7] chore: change default template to system --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 647bf2c..f4918c9 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,7 @@ in { templates = { - default = self.templates.direnv; + default = self.templates.system; system = { path = ./system; description = "";