From 8120a1bf9c933825327f853082afb565b07f42bb Mon Sep 17 00:00:00 2001 From: maningreen Date: Sun, 30 Mar 2025 19:27:34 -0600 Subject: [PATCH 01/22] finished basic devShell for the flake --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 28 ++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..e0fe2d9e1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1743315132, + "narHash": "sha256-6hl6L/tRnwubHcA4pfUUtk542wn2Om+D4UnDhlDW9BE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "52faf482a3889b7619003c0daec593a1912fddc1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..30145fc9e --- /dev/null +++ b/flake.nix @@ -0,0 +1,28 @@ +{ + # TODO: make an actually good desc lol + description = "A flake for the development and installation of the All Thing's Linux discord server's bot tux"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = { self, nixpkgs }: let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + basePkgs = with pkgs; [ + poetry + python313 + + ]; + in { + devShells.${system}.default = pkgs.mkShell { + packages = with pkgs; [ + ] ++ basePkgs; + shellHook = '' + echo "Have fun developing :) - green" + ''; + pkgs.${system}.default = pkgs.stdenv.mkDerivation { + }; + }; + }; +} \ No newline at end of file From d21b295922f9f6ec625d2ba24f372b9003ad4036 Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Sun, 30 Mar 2025 21:35:35 -0500 Subject: [PATCH 02/22] chore: removed *.nix from gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3c8e258e4..18da6a9bd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ __pycache__/ # Replit *.replit -*.nix # C extensions *.so From 58adc4a3cf8d323cdafd6b1bf684cfb0aa79d223 Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Sun, 30 Mar 2025 21:39:13 -0500 Subject: [PATCH 03/22] chore: flake description --- flake.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 30145fc9e..098ff260c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,5 @@ { - # TODO: make an actually good desc lol - description = "A flake for the development and installation of the All Thing's Linux discord server's bot tux"; + description = "All Thing's Linux discord bot - Tux"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; From 38408a11cb36654cae5108b6604da0fa88702a1b Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Sun, 30 Mar 2025 21:41:43 -0500 Subject: [PATCH 04/22] refactor: flake inputs --- flake.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 098ff260c..90eacfaaa 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,11 @@ { description = "All Thing's Linux discord bot - Tux"; - inputs = { - nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + inputs.nixpkgs = { + type = "github"; + owner = "NixOS"; + repo = "nixpkgs"; + ref = "nixos-unstable"; }; outputs = { self, nixpkgs }: let From 754184883490096dec813884109bd6f7a05f20fe Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Sun, 30 Mar 2025 21:42:44 -0500 Subject: [PATCH 05/22] feat: separate shell.nix and multiple systems --- flake.lock | 4 ++-- flake.nix | 37 ++++++++++++++++++++----------------- shell.nix | 16 ++++++++++++++++ 3 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 shell.nix diff --git a/flake.lock b/flake.lock index e0fe2d9e1..182806958 100644 --- a/flake.lock +++ b/flake.lock @@ -4,13 +4,13 @@ "locked": { "lastModified": 1743315132, "narHash": "sha256-6hl6L/tRnwubHcA4pfUUtk542wn2Om+D4UnDhlDW9BE=", - "owner": "nixos", + "owner": "NixOS", "repo": "nixpkgs", "rev": "52faf482a3889b7619003c0daec593a1912fddc1", "type": "github" }, "original": { - "owner": "nixos", + "owner": "NixOS", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" diff --git a/flake.nix b/flake.nix index 90eacfaaa..492845964 100644 --- a/flake.nix +++ b/flake.nix @@ -8,23 +8,26 @@ ref = "nixos-unstable"; }; - outputs = { self, nixpkgs }: let - system = "x86_64-linux"; - pkgs = import nixpkgs { inherit system; }; - basePkgs = with pkgs; [ - poetry - python313 + outputs = { + self, + nixpkgs, + ... + }: + let + supportedSystems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; - ]; - in { - devShells.${system}.default = pkgs.mkShell { - packages = with pkgs; [ - ] ++ basePkgs; - shellHook = '' - echo "Have fun developing :) - green" - ''; - pkgs.${system}.default = pkgs.stdenv.mkDerivation { - }; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + in { + devShells = forAllSystems (system: let + pkgs = nixpkgs.legacyPackages.${system}; + in { + tux = pkgs.callPackage ./shell.nix { inherit pkgs; }; + default = self.devShells.${system}.tux; + }); }; - }; } \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 000000000..76ae93852 --- /dev/null +++ b/shell.nix @@ -0,0 +1,16 @@ +{ pkgs ? import {} }: + +pkgs.mkShell { + packages = with pkgs; [ + python313 + poetry + ]; + + shellHook = '' + # enters the user's preferred shell + $(grep $USER /etc/passwd | sed 's|.*:||g' | tr -d '\n') + + # exits after child shell exits + exit + ''; +} \ No newline at end of file From 690a7bab6b755ae3175443ca2272dc45dfd2490e Mon Sep 17 00:00:00 2001 From: maningreen Date: Sun, 30 Mar 2025 21:12:04 -0600 Subject: [PATCH 06/22] Update shell.nix Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- shell.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell.nix b/shell.nix index 76ae93852..3a7a3e1ef 100644 --- a/shell.nix +++ b/shell.nix @@ -7,8 +7,8 @@ pkgs.mkShell { ]; shellHook = '' - # enters the user's preferred shell - $(grep $USER /etc/passwd | sed 's|.*:||g' | tr -d '\n') + # enters the user's preferred shell using a more robust method + $(getent passwd $(id -un) | cut -d: -f7 | tr -d '\n') # exits after child shell exits exit From f5e393ad02e807afcd4f1459d277d393fc813f65 Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Mon, 31 Mar 2025 22:04:00 -0500 Subject: [PATCH 07/22] feat: added direnv support --- .envrc | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 5 ++++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..56d31b62f --- /dev/null +++ b/.envrc @@ -0,0 +1,50 @@ +# For flake's devShell: +use flake . + + + +# Below are env vars: + +# +# Required +# + +# If in production mode: + +# DEV=False +export PROD_DATABASE_URL="" +export PROD_TOKEN="" + +# If in development mode: + +# DEV=True +export DEV_DATABASE_URL="" +export DEV_TOKEN="" + +# +# Optional +# + +export INFLUXDB_TOKEN="" +export INFLUXDB_URL="" +export INFLUXDB_ORG="" + +export SENTRY_URL="" + +export PROD_COG_IGNORE_LIST="rolecount,mail" # These are ATL specific cogs that are not needed in Tux unless you are ATL +export DEV_COG_IGNORE_LIST= + +export GITHUB_APP_ID= +export GITHUB_CLIENT_ID="" +export GITHUB_CLIENT_SECRET="" +export GITHUB_PUBLIC_KEY="" +export GITHUB_INSTALLATION_ID= + +export GITHUB_PRIVATE_KEY_BASE64="" + +export GITHUB_REPO_URL= +export GITHUB_REPO_OWNER= +export GITHUB_REPO= + +export MAILCOW_API_KEY= +export MAILCOW_API_URL= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 18da6a9bd..8a9f47c12 100644 --- a/.gitignore +++ b/.gitignore @@ -171,4 +171,7 @@ tux/extensions/* # misc slim.report.json -prisma_binaries/ \ No newline at end of file +prisma_binaries/ + +# direnv +.direnv/ From a1b9dc24b4348ec2143d330f3f6d8e81807107e3 Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Mon, 31 Mar 2025 22:04:17 -0500 Subject: [PATCH 08/22] feat(nix shell): added git and jq --- shell.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell.nix b/shell.nix index 3a7a3e1ef..b4835e60a 100644 --- a/shell.nix +++ b/shell.nix @@ -4,6 +4,8 @@ pkgs.mkShell { packages = with pkgs; [ python313 poetry + git + jq ]; shellHook = '' From cfab5be6a7252668499c026157e84213e98f12b2 Mon Sep 17 00:00:00 2001 From: maningreen Date: Sun, 30 Mar 2025 19:27:34 -0600 Subject: [PATCH 09/22] finished basic devShell for the flake --- flake.lock | 1 + flake.nix | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.lock b/flake.lock index 182806958..986cdd208 100644 --- a/flake.lock +++ b/flake.lock @@ -5,6 +5,7 @@ "lastModified": 1743315132, "narHash": "sha256-6hl6L/tRnwubHcA4pfUUtk542wn2Om+D4UnDhlDW9BE=", "owner": "NixOS", + "owner": "nixos", "repo": "nixpkgs", "rev": "52faf482a3889b7619003c0daec593a1912fddc1", "type": "github" diff --git a/flake.nix b/flake.nix index 492845964..5dc492023 100644 --- a/flake.nix +++ b/flake.nix @@ -30,4 +30,4 @@ default = self.devShells.${system}.tux; }); }; -} \ No newline at end of file +} From 27ec2013e47a0578471af100b8d0c7ff722da098 Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Sun, 30 Mar 2025 21:42:44 -0500 Subject: [PATCH 10/22] feat: separate shell.nix and multiple systems --- shell.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell.nix b/shell.nix index b4835e60a..78d5a53c5 100644 --- a/shell.nix +++ b/shell.nix @@ -15,4 +15,4 @@ pkgs.mkShell { # exits after child shell exits exit ''; -} \ No newline at end of file +} From 60055c7951e89a68d8fb9512d9d89a4d5ee5e61b Mon Sep 17 00:00:00 2001 From: maningreen Date: Sun, 30 Mar 2025 19:27:34 -0600 Subject: [PATCH 11/22] finished basic devShell for the flake --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 28 ++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..e0fe2d9e1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1743315132, + "narHash": "sha256-6hl6L/tRnwubHcA4pfUUtk542wn2Om+D4UnDhlDW9BE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "52faf482a3889b7619003c0daec593a1912fddc1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..30145fc9e --- /dev/null +++ b/flake.nix @@ -0,0 +1,28 @@ +{ + # TODO: make an actually good desc lol + description = "A flake for the development and installation of the All Thing's Linux discord server's bot tux"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = { self, nixpkgs }: let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + basePkgs = with pkgs; [ + poetry + python313 + + ]; + in { + devShells.${system}.default = pkgs.mkShell { + packages = with pkgs; [ + ] ++ basePkgs; + shellHook = '' + echo "Have fun developing :) - green" + ''; + pkgs.${system}.default = pkgs.stdenv.mkDerivation { + }; + }; + }; +} \ No newline at end of file From 1dc2d5b8ea5ed373c1001c420c237c2164896eab Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Sun, 30 Mar 2025 21:35:35 -0500 Subject: [PATCH 12/22] chore: removed *.nix from gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3c8e258e4..18da6a9bd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ __pycache__/ # Replit *.replit -*.nix # C extensions *.so From 82fc21628e6b52a1c56e6b78844832ae6a4a891c Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Sun, 30 Mar 2025 21:39:13 -0500 Subject: [PATCH 13/22] chore: flake description --- flake.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 30145fc9e..098ff260c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,5 @@ { - # TODO: make an actually good desc lol - description = "A flake for the development and installation of the All Thing's Linux discord server's bot tux"; + description = "All Thing's Linux discord bot - Tux"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; From 6c784beaede9ada4590c9d4fcdd675445f93bfef Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Sun, 30 Mar 2025 21:41:43 -0500 Subject: [PATCH 14/22] refactor: flake inputs --- flake.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 098ff260c..90eacfaaa 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,11 @@ { description = "All Thing's Linux discord bot - Tux"; - inputs = { - nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + inputs.nixpkgs = { + type = "github"; + owner = "NixOS"; + repo = "nixpkgs"; + ref = "nixos-unstable"; }; outputs = { self, nixpkgs }: let From 8a1cb39c695a1890045fe686c90117eb12572091 Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Sun, 30 Mar 2025 21:42:44 -0500 Subject: [PATCH 15/22] feat: separate shell.nix and multiple systems --- flake.lock | 4 ++-- flake.nix | 37 ++++++++++++++++++++----------------- shell.nix | 16 ++++++++++++++++ 3 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 shell.nix diff --git a/flake.lock b/flake.lock index e0fe2d9e1..182806958 100644 --- a/flake.lock +++ b/flake.lock @@ -4,13 +4,13 @@ "locked": { "lastModified": 1743315132, "narHash": "sha256-6hl6L/tRnwubHcA4pfUUtk542wn2Om+D4UnDhlDW9BE=", - "owner": "nixos", + "owner": "NixOS", "repo": "nixpkgs", "rev": "52faf482a3889b7619003c0daec593a1912fddc1", "type": "github" }, "original": { - "owner": "nixos", + "owner": "NixOS", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" diff --git a/flake.nix b/flake.nix index 90eacfaaa..492845964 100644 --- a/flake.nix +++ b/flake.nix @@ -8,23 +8,26 @@ ref = "nixos-unstable"; }; - outputs = { self, nixpkgs }: let - system = "x86_64-linux"; - pkgs = import nixpkgs { inherit system; }; - basePkgs = with pkgs; [ - poetry - python313 + outputs = { + self, + nixpkgs, + ... + }: + let + supportedSystems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; - ]; - in { - devShells.${system}.default = pkgs.mkShell { - packages = with pkgs; [ - ] ++ basePkgs; - shellHook = '' - echo "Have fun developing :) - green" - ''; - pkgs.${system}.default = pkgs.stdenv.mkDerivation { - }; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + in { + devShells = forAllSystems (system: let + pkgs = nixpkgs.legacyPackages.${system}; + in { + tux = pkgs.callPackage ./shell.nix { inherit pkgs; }; + default = self.devShells.${system}.tux; + }); }; - }; } \ No newline at end of file diff --git a/shell.nix b/shell.nix new file mode 100644 index 000000000..76ae93852 --- /dev/null +++ b/shell.nix @@ -0,0 +1,16 @@ +{ pkgs ? import {} }: + +pkgs.mkShell { + packages = with pkgs; [ + python313 + poetry + ]; + + shellHook = '' + # enters the user's preferred shell + $(grep $USER /etc/passwd | sed 's|.*:||g' | tr -d '\n') + + # exits after child shell exits + exit + ''; +} \ No newline at end of file From c28dc6acead07a69c8e2f59aceaf6f65da695632 Mon Sep 17 00:00:00 2001 From: maningreen Date: Sun, 30 Mar 2025 21:12:04 -0600 Subject: [PATCH 16/22] Update shell.nix Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- shell.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell.nix b/shell.nix index 76ae93852..3a7a3e1ef 100644 --- a/shell.nix +++ b/shell.nix @@ -7,8 +7,8 @@ pkgs.mkShell { ]; shellHook = '' - # enters the user's preferred shell - $(grep $USER /etc/passwd | sed 's|.*:||g' | tr -d '\n') + # enters the user's preferred shell using a more robust method + $(getent passwd $(id -un) | cut -d: -f7 | tr -d '\n') # exits after child shell exits exit From a7cc49ab68e2e4c0ea0c583766a850ab612a444c Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Mon, 31 Mar 2025 22:04:00 -0500 Subject: [PATCH 17/22] feat: added direnv support --- .envrc | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 5 ++++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..56d31b62f --- /dev/null +++ b/.envrc @@ -0,0 +1,50 @@ +# For flake's devShell: +use flake . + + + +# Below are env vars: + +# +# Required +# + +# If in production mode: + +# DEV=False +export PROD_DATABASE_URL="" +export PROD_TOKEN="" + +# If in development mode: + +# DEV=True +export DEV_DATABASE_URL="" +export DEV_TOKEN="" + +# +# Optional +# + +export INFLUXDB_TOKEN="" +export INFLUXDB_URL="" +export INFLUXDB_ORG="" + +export SENTRY_URL="" + +export PROD_COG_IGNORE_LIST="rolecount,mail" # These are ATL specific cogs that are not needed in Tux unless you are ATL +export DEV_COG_IGNORE_LIST= + +export GITHUB_APP_ID= +export GITHUB_CLIENT_ID="" +export GITHUB_CLIENT_SECRET="" +export GITHUB_PUBLIC_KEY="" +export GITHUB_INSTALLATION_ID= + +export GITHUB_PRIVATE_KEY_BASE64="" + +export GITHUB_REPO_URL= +export GITHUB_REPO_OWNER= +export GITHUB_REPO= + +export MAILCOW_API_KEY= +export MAILCOW_API_URL= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 18da6a9bd..8a9f47c12 100644 --- a/.gitignore +++ b/.gitignore @@ -171,4 +171,7 @@ tux/extensions/* # misc slim.report.json -prisma_binaries/ \ No newline at end of file +prisma_binaries/ + +# direnv +.direnv/ From c36b8c84371b20b32a6dc0c7e9c98245303cd24b Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Mon, 31 Mar 2025 22:04:17 -0500 Subject: [PATCH 18/22] feat(nix shell): added git and jq --- shell.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell.nix b/shell.nix index 3a7a3e1ef..b4835e60a 100644 --- a/shell.nix +++ b/shell.nix @@ -4,6 +4,8 @@ pkgs.mkShell { packages = with pkgs; [ python313 poetry + git + jq ]; shellHook = '' From 8322b4909f2b03c62a9869a64618edb798367732 Mon Sep 17 00:00:00 2001 From: maningreen Date: Sun, 30 Mar 2025 19:27:34 -0600 Subject: [PATCH 19/22] finished basic devShell for the flake --- flake.lock | 1 + flake.nix | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.lock b/flake.lock index 182806958..986cdd208 100644 --- a/flake.lock +++ b/flake.lock @@ -5,6 +5,7 @@ "lastModified": 1743315132, "narHash": "sha256-6hl6L/tRnwubHcA4pfUUtk542wn2Om+D4UnDhlDW9BE=", "owner": "NixOS", + "owner": "nixos", "repo": "nixpkgs", "rev": "52faf482a3889b7619003c0daec593a1912fddc1", "type": "github" diff --git a/flake.nix b/flake.nix index 492845964..5dc492023 100644 --- a/flake.nix +++ b/flake.nix @@ -30,4 +30,4 @@ default = self.devShells.${system}.tux; }); }; -} \ No newline at end of file +} From f6ebe17c369057f17d2902543e8c615ef91292e9 Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Sun, 30 Mar 2025 21:42:44 -0500 Subject: [PATCH 20/22] feat: separate shell.nix and multiple systems --- shell.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell.nix b/shell.nix index b4835e60a..78d5a53c5 100644 --- a/shell.nix +++ b/shell.nix @@ -15,4 +15,4 @@ pkgs.mkShell { # exits after child shell exits exit ''; -} \ No newline at end of file +} From ec41ba8d5777230a6d8a205550984ac0c9b937a2 Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Tue, 13 May 2025 17:25:18 -0500 Subject: [PATCH 21/22] chore: remove .envrc --- .envrc | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 .envrc diff --git a/.envrc b/.envrc deleted file mode 100644 index 56d31b62f..000000000 --- a/.envrc +++ /dev/null @@ -1,50 +0,0 @@ -# For flake's devShell: -use flake . - - - -# Below are env vars: - -# -# Required -# - -# If in production mode: - -# DEV=False -export PROD_DATABASE_URL="" -export PROD_TOKEN="" - -# If in development mode: - -# DEV=True -export DEV_DATABASE_URL="" -export DEV_TOKEN="" - -# -# Optional -# - -export INFLUXDB_TOKEN="" -export INFLUXDB_URL="" -export INFLUXDB_ORG="" - -export SENTRY_URL="" - -export PROD_COG_IGNORE_LIST="rolecount,mail" # These are ATL specific cogs that are not needed in Tux unless you are ATL -export DEV_COG_IGNORE_LIST= - -export GITHUB_APP_ID= -export GITHUB_CLIENT_ID="" -export GITHUB_CLIENT_SECRET="" -export GITHUB_PUBLIC_KEY="" -export GITHUB_INSTALLATION_ID= - -export GITHUB_PRIVATE_KEY_BASE64="" - -export GITHUB_REPO_URL= -export GITHUB_REPO_OWNER= -export GITHUB_REPO= - -export MAILCOW_API_KEY= -export MAILCOW_API_URL= \ No newline at end of file From ddac04f7de41b32cfcfae462dda36dee65707fa9 Mon Sep 17 00:00:00 2001 From: midirhee12 Date: Tue, 13 May 2025 17:26:38 -0500 Subject: [PATCH 22/22] feat: added flake-parts & created envrc generator --- flake.lock | 36 ++++++++++++++++++++++++++++++- flake.nix | 62 ++++++++++++++++++++++++++++++++++++++++-------------- shell.nix | 15 ++++++++++--- 3 files changed, 93 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index 986cdd208..34ba8dfe4 100644 --- a/flake.lock +++ b/flake.lock @@ -1,10 +1,28 @@ { "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "ref": "main", + "repo": "flake-parts", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1743315132, "narHash": "sha256-6hl6L/tRnwubHcA4pfUUtk542wn2Om+D4UnDhlDW9BE=", - "owner": "NixOS", "owner": "nixos", "repo": "nixpkgs", "rev": "52faf482a3889b7619003c0daec593a1912fddc1", @@ -17,8 +35,24 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1743296961, + "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "root": { "inputs": { + "flake-parts": "flake-parts", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 5dc492023..dd617b429 100644 --- a/flake.nix +++ b/flake.nix @@ -1,33 +1,63 @@ { description = "All Thing's Linux discord bot - Tux"; - inputs.nixpkgs = { - type = "github"; - owner = "NixOS"; - repo = "nixpkgs"; - ref = "nixos-unstable"; + inputs = { + nixpkgs = { + type = "github"; + owner = "NixOS"; + repo = "nixpkgs"; + ref = "nixos-unstable"; + }; + + flake-parts = { + type = "github"; + owner = "hercules-ci"; + repo = "flake-parts"; + ref = "main"; + }; }; - outputs = { + outputs = inputs@{ self, nixpkgs, + flake-parts, ... }: - let - supportedSystems = [ + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - in { - devShells = forAllSystems (system: let - pkgs = nixpkgs.legacyPackages.${system}; - in { - tux = pkgs.callPackage ./shell.nix { inherit pkgs; }; - default = self.devShells.${system}.tux; - }); + perSystem = { pkgs, self', system, ... }: { + devShells = { + default = self'.devShells.tux; + tux = pkgs.callPackage ./shell.nix { inherit pkgs self; }; + }; + + apps.envrc = { + type = "app"; + program = self'.packages.envrc; + }; + + # Creates .envrc if does not exist + packages.envrc = pkgs.writeShellScriptBin "envrc" '' + echo + + if [ ! -e ".envrc" ]; then + echo "Creating .envrc" + printf "use flake .\n\n\n" | cat - .env.example > .envrc + echo + + echo "The directory is now set up for direnv usage." + echo + else + echo "Please delete .envrc if you wish to recreate it." + echo + fi + ''; + }; }; } diff --git a/shell.nix b/shell.nix index 78d5a53c5..5c029a288 100644 --- a/shell.nix +++ b/shell.nix @@ -1,6 +1,10 @@ -{ pkgs ? import {} }: +{ pkgs ? import {}, self ? null }: pkgs.mkShell { + buildInputs = if self == null then [] else [ + self.packages.${pkgs.system}.envrc + ]; + packages = with pkgs; [ python313 poetry @@ -9,10 +13,15 @@ pkgs.mkShell { ]; shellHook = '' - # enters the user's preferred shell using a more robust method + # See perSystem.packages.envrc + if command -v envrc >/dev/null 2>&1; then + envrc + fi + + # Enters the user's preferred shell using a more robust method $(getent passwd $(id -un) | cut -d: -f7 | tr -d '\n') - # exits after child shell exits + # Exits after child shell exits exit ''; }