commit 2e435e5498cf86c173c9c12b167f1b20241da2eb
parent d1e9400ec1ea8ce9e1dc668231887b80302c6375
Author: Vincent Demeester <vincent@sbr.pm>
Date: Thu, 28 May 2020 18:41:20 +0200
systems: use modules/ as entrypoint 👼
Less import, lots of default 😛
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat:
17 files changed, 250 insertions(+), 65 deletions(-)
diff --git a/hardware/dell-latitude-e6540.nix b/hardware/dell-latitude-e6540.nix
@@ -25,5 +25,6 @@
driSupport32Bit = true;
};
};
+ nix.maxJobs = 8;
services.acpid.enable = true;
}
diff --git a/hardware/lenovo-p50.nix b/hardware/lenovo-p50.nix
@@ -1,4 +1,4 @@
-{ config, pkgs, ... }:
+{ config, pkgs, lib, ... }:
let
sources = import ../nix/sources.nix;
in
@@ -18,6 +18,7 @@ in
intelBusId = "PCI:0:2:0";
};
};
+ nix.maxJobs = 12;
services.throttled.enable = lib.mkDefault true;
services = {
tlp = {
diff --git a/hardware/thinkpad-t460s.nix b/hardware/thinkpad-t460s.nix
@@ -8,6 +8,7 @@ in
(sources.nixos-hardware + "/common/pc/ssd")
./thinkpad.nix
];
+ nix.maxJobs = 12;
services = {
tlp = {
extraConfig = ''
diff --git a/hardware/thinkpad-x220.nix b/hardware/thinkpad-x220.nix
@@ -15,6 +15,7 @@ in
options iwlwifi 11n_disable=1
'';
};
+ nix.maxJobs = 8;
security = {
pam.services = {
slimlock.fprintAuth = false;
diff --git a/modules/core/default.nix b/modules/core/default.nix
@@ -0,0 +1,8 @@
+{
+ imports = [
+ (import ../../nix).home-manager
+ ./home-manager.nix
+ ./nix.nix
+ ./nur.nix
+ ];
+}
diff --git a/modules/core/home-manager.nix b/modules/core/home-manager.nix
@@ -0,0 +1,17 @@
+{ config, lib, ... }:
+
+with lib;
+let
+ cfg = config.core.home-manager;
+in
+{
+ options = {
+ core.home-manager = {
+ enable = mkOption { type = types.bool; default = true; description = "Enable core.home-manager"; };
+ };
+ };
+ config = mkIf cfg.enable {
+ home-manager.useUserPackages = true;
+ home-manager.useGlobalPkgs = true;
+ };
+}
diff --git a/modules/core/nix.nix b/modules/core/nix.nix
@@ -0,0 +1,103 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+ dummyConfig = pkgs.writeText "configuration.nix" ''
+ # assert builtins.trace "This is a dummy config, use switch!" false;
+ {}
+ '';
+ cfg = config.core.nix;
+in
+{
+ options = {
+ core.nix = {
+ enable = mkOption { type = types.bool; default = true; description = "Enable core.nix"; };
+ gcDates = mkOption {
+ default = "weekly";
+ description = "Specification (in the format described by systemd.time(7)) of the time at which the garbage collector will run. ";
+ type = types.str;
+ };
+ olderThan = mkOption {
+ default = "15d";
+ description = "Number of day to keep when garbage collect";
+ type = types.str;
+ };
+ buildCores = mkOption {
+ type = types.int;
+ default = 2;
+ example = 4;
+ description = ''
+ Maximum number of concurrent tasks during one build.
+ '';
+ };
+ localCaches = mkOption {
+ default = [ "http://nix.cache.home" ];
+ description = "List of local nix caches";
+ type = types.listOf types.str;
+ };
+ };
+ };
+ config = mkIf cfg.enable {
+ nix = {
+ allowedUsers = [ "@wheel" ];
+ binaryCaches = cfg.localCaches ++ [
+ "https://cache.nixos.org/"
+ "https://r-ryantm.cachix.org"
+ "https://vdemeester.cachix.org"
+ "https://shortbrain.cachix.org"
+ ];
+ binaryCachePublicKeys = [
+ "r-ryantm.cachix.org-1:gkUbLkouDAyvBdpBX0JOdIiD2/DP1ldF3Z3Y6Gqcc4c="
+ "vdemeester.cachix.org-1:uCECG6so7v1rs77c5NFz2dCePwd+PGNeZ6E5DrkT7F0="
+ "shortbrain.cachix.org-1:dqXcXzM0yXs3eo9ChmMfmob93eemwNyhTx7wCR4IjeQ="
+ "mic92.cachix.org-1:gi8IhgiT3CYZnJsaW7fxznzTkMUOn1RY4GmXdT/nXYQ="
+ ];
+ buildCores = cfg.buildCores;
+ daemonIONiceLevel = 5;
+ daemonNiceLevel = 10;
+ # if hydra is down, don't wait forever
+ extraOptions = ''
+ connect-timeout = 20
+ build-cores = 0
+ keep-outputs = true
+ keep-derivations = true
+ '';
+ gc = {
+ automatic = true;
+ dates = cfg.gcDates;
+ options = "--delete-older-than ${cfg.olderThan}";
+ };
+ nixPath = [
+ "nixos-config=${dummyConfig}"
+ "nixpkgs=/run/current-system/nixpkgs"
+ "nixpkgs-overlays=/run/current-system/overlays/compat"
+ ];
+ optimise = {
+ automatic = true;
+ dates = [ "01:10" "12:10" ];
+ };
+ nrBuildUsers = config.nix.maxJobs * 2;
+ trustedUsers = [ "root" "@wheel" ];
+ useSandbox = true;
+ };
+
+ nixpkgs = {
+ overlays = [
+ (import ../../overlays/sbr.nix)
+ (import ../../overlays/unstable.nix)
+ (import ../../nix).emacs
+ ];
+ config = {
+ allowUnfree = true;
+ };
+ };
+ system = {
+ extraSystemBuilderCmds = ''
+ ln -sv ${pkgs.path} $out/nixpkgs
+ ln -sv ${../overlays} $out/overlays
+ '';
+
+ stateVersion = "20.03";
+ };
+ };
+}
diff --git a/modules/core/nur.nix b/modules/core/nur.nix
@@ -0,0 +1,20 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+ cfg = config.core.nur;
+in
+{
+ options = {
+ core.nur = {
+ enable = mkOption { type = types.bool; default = true; description = "Enable core.nur"; };
+ };
+ };
+ config = mkIf cfg.enable {
+ nixpkgs.config = {
+ packageOverrides = pkgs: {
+ nur = (import ../../nix).nur { inherit pkgs; };
+ };
+ };
+ };
+}
diff --git a/modules/default.nix b/modules/default.nix
@@ -0,0 +1,10 @@
+{
+ imports = [
+ ./core
+ ./hardware
+ ./profiles
+ ./programs
+ ./services
+ ./virtualisation
+ ];
+}
diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix
@@ -0,0 +1,6 @@
+{
+ imports = [
+ # remove "nixos"
+ ./sane-extra-config.nixos.nix
+ ];
+}
diff --git a/modules/profiles/default.nix b/modules/profiles/default.nix
@@ -0,0 +1,32 @@
+{
+ imports = [
+ # Remove "nixos" from here
+ ./avahi.nixos.nix
+ ./base.nixos.nix
+ ./buildkit.nixos.nix
+ ./containerd.nixos.nix
+ ./desktop.nixos.nix
+ ./dev.nixos.nix
+ ./docker.nixos.nix
+ ./fish.nixos.nix
+ ./gaming.nixos.nix
+ ./git.nixos.nix
+ ./home.nixos.nix
+ ./i18n.nixos.nix
+ ./ipfs.nixos.nix
+ ./laptop.nixos.nix
+ ./mail.nixos.nix
+ ./nix-auto-update.nixos.nix
+ ./printing.nixos.nix
+ ./pulseaudio.nixos.nix
+ ./qemu.nixos.nix
+ ./scanning.nixos.nix
+ ./ssh.nixos.nix
+ ./syncthing.nixos.nix
+ ./users.nixos.nix
+ ./virtualization.nixos.nix
+ ./wireguard.server.nixos.nix
+ ./yubikey.nixos.nix
+ ./zsh.nixos.nix
+ ];
+}
diff --git a/modules/programs/default.nix b/modules/programs/default.nix
@@ -0,0 +1,6 @@
+{
+ imports = [
+ # Remove "nixos" from here
+ ./podman.nixos.nix
+ ];
+}
diff --git a/modules/services/default.nix b/modules/services/default.nix
@@ -0,0 +1,3 @@
+{
+ imports = [ ];
+}
diff --git a/modules/virtualisation/default.nix b/modules/virtualisation/default.nix
@@ -0,0 +1,7 @@
+{
+ imports = [
+ # Remove "nixos" from here
+ ./buildkit.nixos.nix
+ ./containerd.nixos.nix
+ ];
+}
diff --git a/nix/default.nix b/nix/default.nix
@@ -11,4 +11,5 @@ rec {
emacs = import sources.emacs-overlay;
gitignore = import sources.gitignore;
nixos-hardware = import sources.nixos-hardware;
+ nur = import sources.nur;
}
diff --git a/nix/sources.json b/nix/sources.json
@@ -1,4 +1,16 @@
{
+ "NUR": {
+ "branch": "master",
+ "description": "Nix User Repository: User contributed nix packages [maintainer=@Mic92]",
+ "homepage": "",
+ "owner": "nix-community",
+ "repo": "NUR",
+ "rev": "b413faf970b1b90ec590b713026bead9ccfcba61",
+ "sha256": "146db2c82mybjjb1hpjcv4f7n0glz8xclpj898ds74kgj324r0pq",
+ "type": "tarball",
+ "url": "https://github.com/nix-community/NUR/archive/b413faf970b1b90ec590b713026bead9ccfcba61.tar.gz",
+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
+ },
"emacs-overlay": {
"branch": "master",
"description": "Bleeding edge emacs overlay [maintainer=@adisbladis] ",
diff --git a/systems/hokkaido.nix b/systems/hokkaido.nix
@@ -1,30 +1,30 @@
{ lib, pkgs, ... }:
let
- dummyConfig = pkgs.writeText "configuration.nix" ''
- # assert builtins.trace "This is a dummy config, use switch!" false;
- {}
- '';
inCi = builtins.pathExists /home/build;
enableHome = !inCi;
in
{
imports = [
- (import ../nix).home-manager
- ../modules/module-list.nixos.nix
# hardware
../hardware/thinkpad-x220.nix
+ # modules
+ ../modules
];
- profiles.home = enableHome;
- profiles.users.withMachines = enableHome;
- profiles.mail.enable = enableHome;
-
- networking = {
- hostName = "hokkaido";
- };
+ fileSystems."/" =
+ {
+ device = "/dev/disk/by-uuid/884a3d57-f652-49b2-9c8b-f6eebd5edbeb";
+ fsType = "ext4";
+ };
+ fileSystems."/boot" =
+ {
+ device = "/dev/disk/by-uuid/C036-34B9";
+ fsType = "vfat";
+ };
+ swapDevices =
+ [{ device = "/dev/disk/by-uuid/e1833693-77ac-4d52-bcc7-54d082788639"; }];
# FIXME move this away
- home-manager.useUserPackages = true;
home-manager.users.vincent = { pkgs, ... }: {
imports = [
# Default profile with default configuration
@@ -39,60 +39,16 @@ in
home.packages = with pkgs; [ htop ];
};
- fileSystems."/" =
- {
- device = "/dev/disk/by-uuid/884a3d57-f652-49b2-9c8b-f6eebd5edbeb";
- fsType = "ext4";
- };
-
- fileSystems."/boot" =
- {
- device = "/dev/disk/by-uuid/C036-34B9";
- fsType = "vfat";
- };
-
- swapDevices =
- [{ device = "/dev/disk/by-uuid/e1833693-77ac-4d52-bcc7-54d082788639"; }];
+ networking = {
+ hostName = "hokkaido";
+ };
profiles = {
+ home = enableHome;
avahi.enable = true;
git.enable = true;
ssh.enable = true;
- nix-config.buildCores = 2;
- };
-
- # FIXME: move this away
- profiles.nix-config.enable = false;
- home-manager.useGlobalPkgs = true;
- nix.nixPath = [
- "nixos-config=${dummyConfig}"
- "nixpkgs=/run/current-system/nixpkgs"
- "nixpkgs-overlays=/run/current-system/overlays/compat"
- ];
-
- nixpkgs = {
- overlays = [
- (import ../overlays/sbr.nix)
- (import ../overlays/unstable.nix)
- (import ../nix).emacs
- ];
- config = {
- allowUnfree = true;
- packageOverrides = pkgs: {
- nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
- inherit pkgs;
- };
- };
- };
- };
-
- # FIXME: put this in a common
- system = {
- extraSystemBuilderCmds = ''
- ln -sv ${pkgs.path} $out/nixpkgs
- ln -sv ${../overlays} $out/overlays
- '';
-
- stateVersion = "20.03";
+ users.withMachines = enableHome;
+ mail.enable = enableHome;
};
}