From 4d9ffec0b74ecffc4229912b899cb60b69b842e3 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Tue, 14 Nov 2023 22:32:04 +0100 Subject: [PATCH] [direnv] Create module --- nixos/hosts/Tibo-NixDesk/default.nix | 9 +------ nixos/hosts/Tibo-NixFat/default.nix | 9 +------ nixos/modules-old/default.nix | 29 ----------------------- nixos/modules/programs/default.nix | 3 ++- nixos/modules/programs/direnv/default.nix | 22 +++++++++++++++++ 5 files changed, 26 insertions(+), 46 deletions(-) delete mode 100644 nixos/modules-old/default.nix create mode 100644 nixos/modules/programs/direnv/default.nix diff --git a/nixos/hosts/Tibo-NixDesk/default.nix b/nixos/hosts/Tibo-NixDesk/default.nix index cbef30c..7695521 100644 --- a/nixos/hosts/Tibo-NixDesk/default.nix +++ b/nixos/hosts/Tibo-NixDesk/default.nix @@ -19,6 +19,7 @@ }; programs = { + direnv.enable = true; home-manager.enable = true; sops.enable = true; ssh.enable = true; @@ -69,14 +70,6 @@ time.timeZone = "Europe/Brussels"; - nix = { - # Keep derivations so shells don't break (direnv) - extraOptions = '' - keep-outputs = true - keep-derivations = true - ''; - }; - i18n.defaultLocale = "en_GB.UTF-8"; console = { # font = "Lat2-Terminus16"; diff --git a/nixos/hosts/Tibo-NixFat/default.nix b/nixos/hosts/Tibo-NixFat/default.nix index b794143..c00d9a1 100644 --- a/nixos/hosts/Tibo-NixFat/default.nix +++ b/nixos/hosts/Tibo-NixFat/default.nix @@ -19,6 +19,7 @@ }; programs = { + direnv.enable = true; home-manager.enable = true; sops.enable = true; ssh.enable = true; @@ -101,14 +102,6 @@ networkmanager.enable = true; }; - nix = { - # Keep derivations so shells don't break (direnv) - extraOptions = '' - keep-outputs = true - keep-derivations = true - ''; - }; - i18n.defaultLocale = "en_GB.UTF-8"; console = { # font = "Lat2-Terminus16"; diff --git a/nixos/modules-old/default.nix b/nixos/modules-old/default.nix deleted file mode 100644 index 35fb80f..0000000 --- a/nixos/modules-old/default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ inputs, lib, config, pkgs, ... }: - -{ - nix = { - # Allow Nix Flakes - # Keep derivations so shells don't break (direnv) - # If the disk has less than 100MiB, free up to 2GiB by garbage-collecting. - extraOptions = '' - experimental-features = nix-command flakes - keep-outputs = true - keep-derivations = true - min-free = ${toString (100 * 1024 * 1024)} - max-free = ${toString (2048 * 1024 * 1024)} - ''; - # Scheduled garbage-collect - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 30d"; - }; - package = pkgs.nixFlakes; - }; - - i18n.defaultLocale = "en_GB.UTF-8"; - console = { - # font = "Lat2-Terminus16"; - useXkbConfig = true; # use xkbOptions in tty. - }; -} diff --git a/nixos/modules/programs/default.nix b/nixos/modules/programs/default.nix index 6a41a2f..fd61ea8 100644 --- a/nixos/modules/programs/default.nix +++ b/nixos/modules/programs/default.nix @@ -1,8 +1,9 @@ { imports = [ + ./direnv ./home-manager ./sops - ./ssh ./spotify-adblock + ./ssh ]; } diff --git a/nixos/modules/programs/direnv/default.nix b/nixos/modules/programs/direnv/default.nix new file mode 100644 index 0000000..7ecf1b7 --- /dev/null +++ b/nixos/modules/programs/direnv/default.nix @@ -0,0 +1,22 @@ +{ config, lib, pkgs, ... }: + +let + cfg = sisyphus.programs.direnv; +in { + options.sisyphus.programs.direnv.enable = lib.mkEnableOption "direnv"; + + config = lib.mkIf cfg.enable { + programs.direnv = { + enable = true; + nix-direnv.enable = true; # Use nix-specific direnv. + persistDerivations = true; # Sets the extraOptions listed below. + }; + + # This is also done by setting programs.direnv.persistDerivations. + # Keep derivations so shells don't break. + nix.extraOption = '' + keep-outputs = true + keep-derivations = true + ''; + }; +};