From 91aea7e1e180bd48af21ae8781bf00a875cb88a0 Mon Sep 17 00:00:00 2001 From: Julien Malka Date: Sun, 5 Dec 2021 23:29:51 +0100 Subject: [PATCH] More refactoring --- config/hosts/lisa.nix | 64 -------------- config/web-services/lisa-services.nix | 121 -------------------------- flake.nix | 86 +++++++++++------- machines/enigma.nix | 0 machines/lisa.nix | 64 ++++++++++++++ machines/macintosh.nix | 0 machines/newton.nix | 0 7 files changed, 117 insertions(+), 218 deletions(-) delete mode 100644 config/hosts/lisa.nix delete mode 100644 config/web-services/lisa-services.nix delete mode 100644 machines/enigma.nix delete mode 100644 machines/macintosh.nix delete mode 100644 machines/newton.nix diff --git a/config/hosts/lisa.nix b/config/hosts/lisa.nix deleted file mode 100644 index 972d95c..0000000 --- a/config/hosts/lisa.nix +++ /dev/null @@ -1,64 +0,0 @@ -# Do not modify this file! It was generated by ‘nixos-generate-config’ -# and may be overwritten by future invocations. Please make changes -# to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: - -{ - imports = - [ - (modulesPath + "/profiles/qemu-guest.nix") - ]; - - boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "sd_mod" "sr_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ ]; - boot.extraModulePackages = [ ]; - - fileSystems."/" = - { device = "/dev/disk/by-uuid/eaec3978-f462-4634-95e6-06d59512deb8"; - fsType = "ext4"; - }; - - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/EAD2-51DB"; - fsType = "vfat"; - }; - - swapDevices = - [ { device = "/dev/disk/by-uuid/c19ec918-ba8c-4bab-9ee0-831465cb432e"; } - ]; - - nix.maxJobs = lib.mkDefault 8; - - # Specific to lisa but not hardware - - - # Use the systemd-boot EFI boot loader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - luj.mediaserver.enable = true; - networking.hostName = "lisa"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - - # The global useDHCP flag is deprecated, therefore explicitly set to false here. - # Per-interface useDHCP will be mandatory in the future, so this generated config - # replicates the default behaviour. - networking.useDHCP = false; - networking.interfaces.ens18.useDHCP = true; - networking.interfaces.ens19.useDHCP = false; - networking.interfaces.ens19.ipv6.addresses = [ { - address = "2a01:e0a:5f9:9681:5880:c9ff:fe9f:3dfb"; - prefixLength = 120; - } ]; - - networking.firewall.allowedTCPPorts = [22 80 443 8096 8920]; - networking.firewall.allowedUDPPorts = [22 80 443 1900 7359]; - networking.firewall.allowedUDPPortRanges = [ { from = 60000; to = 61000;}]; - - - system.stateVersion = "20.09"; # Did you read the comment? - - - - -} diff --git a/config/web-services/lisa-services.nix b/config/web-services/lisa-services.nix deleted file mode 100644 index 74a0b32..0000000 --- a/config/web-services/lisa-services.nix +++ /dev/null @@ -1,121 +0,0 @@ -{ config, pkgs, ... }: -{ - -services.jellyfin = { - enable = true; - group = "tv"; - package = pkgs.jellyfin; -}; - -services.sonarr = { - enable = true; - openFirewall = true; - group = "tv"; -}; - -services.radarr = { - enable = true; - openFirewall = true; - group = "tv"; -}; - -services.transmission = { - enable = true; - group = "tv"; - downloadDirPermissions = "774"; - settings = { - rpc-port = 9091; - download-dir = "/home/transmission/Downloads/"; - incomplete-dir = "/home/transmission/Incomplete/"; - incomplete-dir-enable = true; - }; -}; - -services.jackett = { - enable = true; - openFirewall = true; -}; - - -services.nginx = { - enable = true; - - virtualHosts."julienmalka.me" = { - enableACME = true; - forceSSL = true; - root = "/var/www/julienmalka.me"; - default = true; - }; - - virtualHosts."www.julienmalka.me" = { - enableACME = true; - forceSSL = true; - root = "/var/www/julienmalka.me"; - }; - - virtualHosts."tv.julienmalka.me" = { - addSSL = true; - enableACME = true; - locations."/" = { - proxyPass = "http://localhost:8096"; - }; - }; - - virtualHosts."series.julienmalka.me" = { - addSSL = true; - enableACME = true; - locations."/" = { - proxyPass = "http://localhost:8989"; - }; - }; - - virtualHosts."downloads.julienmalka.me" = { - addSSL = true; - enableACME = true; - locations."/" = { - proxyPass = "http://localhost:9091"; - }; - }; - - virtualHosts."jackett.julienmalka.me" = { - addSSL = true; - enableACME = true; - locations."/" = { - proxyPass = "http://localhost:9117"; - }; - }; - -virtualHosts."films.julienmalka.me" = { - addSSL = true; - enableACME = true; - locations."/" = { - proxyPass = "http://localhost:7878"; - }; - }; - - - - -}; - - - - - - -security.acme.certs = { -"www.julienmalka.me".email = "julien.malka@me.com"; - "julienmalka.me".email = "julien.malka@me.com"; - "tv.julienmalka.me".email = "julien.malka@me.com"; - "series.julienmalka.me".email = "julien.malka@me.com"; - "downloads.julienmalka.me".email = "julien.malka@me.com"; - "jackett.julienmalka.me".email = "julien.malka@me.com"; - "films.julienmalka.me".email = "julien.malka@me.com"; -}; - -security.acme.acceptTerms = true; - - - - -} diff --git a/flake.nix b/flake.nix index 7903e18..961fec1 100644 --- a/flake.nix +++ b/flake.nix @@ -1,43 +1,63 @@ { - description = "A flake for my personnal configurations"; - inputs = { - nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11; - home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + description = "A flake for my personnal configurations"; + inputs = { + nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; - neovim-nightly-overlay = { - url = "github:nix-community/neovim-nightly-overlay"; - }; + neovim-nightly-overlay = { + url = "github:nix-community/neovim-nightly-overlay"; + }; -}; + }; -outputs = { self, home-manager, nixpkgs, neovim-nightly-overlay, nur, ... }@inputs : -{ - nixosModules = builtins.listToAttrs (map (x: { - name = x; - value = import (./modules + "/${x}"); - }) (builtins.attrNames (builtins.readDir ./modules))); - - nixosConfigurations = { - lisa = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = builtins.attrValues self.nixosModules ++ [./configuration.nix ./config/hosts/lisa.nix - home-manager.nixosModules.home-manager { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.julien = import ./config/home/home-lisa.nix; - nixpkgs.overlays = [ - inputs.neovim-nightly-overlay.overlay + outputs = { self, home-manager, nixpkgs, neovim-nightly-overlay, nur, ... }@inputs: + let + importDir = dir: pipe dir [ + builtins.readDir + (mapAttrsToList (name: type: + if type == "regular" && hasSuffix ".nix" name && name != "default.nix" then + [{ name = removeSuffix ".nix" name; value = import (dir + "/${name}"); }] + else if type == "directory" && pathExists (dir + "/${name}/default.nix") then + [{ inherit name; value = import (dir + "/${name}"); }] + else + [ ] + )) + concatLists + listToAttrs + ]; + mkMachine = host: host-config: modules: { + lisa = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = builtins.attrValues modules ++ [ + ./configuration.nix + host-config + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.julien = import ./config/home/home-lisa.nix; + nixpkgs.overlays = [ + inputs.neovim-nightly-overlay.overlay ]; - - }]; + } + ]; + }; + }; + in + { + nixosModules = builtins.listToAttrs (map + (x: { + name = x; + value = import (./modules + "/${x}"); + }) + (builtins.attrNames (builtins.readDir ./modules))); - }; + nixosConfigurations = mapAttrs (name: value: (mkMachine name value nixosModules)) (importDir ./machines); - }; -}; + }; diff --git a/machines/enigma.nix b/machines/enigma.nix deleted file mode 100644 index e69de29..0000000 diff --git a/machines/lisa.nix b/machines/lisa.nix index e69de29..972d95c 100644 --- a/machines/lisa.nix +++ b/machines/lisa.nix @@ -0,0 +1,64 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ + (modulesPath + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/eaec3978-f462-4634-95e6-06d59512deb8"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/EAD2-51DB"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/c19ec918-ba8c-4bab-9ee0-831465cb432e"; } + ]; + + nix.maxJobs = lib.mkDefault 8; + + # Specific to lisa but not hardware + + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + luj.mediaserver.enable = true; + networking.hostName = "lisa"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # The global useDHCP flag is deprecated, therefore explicitly set to false here. + # Per-interface useDHCP will be mandatory in the future, so this generated config + # replicates the default behaviour. + networking.useDHCP = false; + networking.interfaces.ens18.useDHCP = true; + networking.interfaces.ens19.useDHCP = false; + networking.interfaces.ens19.ipv6.addresses = [ { + address = "2a01:e0a:5f9:9681:5880:c9ff:fe9f:3dfb"; + prefixLength = 120; + } ]; + + networking.firewall.allowedTCPPorts = [22 80 443 8096 8920]; + networking.firewall.allowedUDPPorts = [22 80 443 1900 7359]; + networking.firewall.allowedUDPPortRanges = [ { from = 60000; to = 61000;}]; + + + system.stateVersion = "20.09"; # Did you read the comment? + + + + +} diff --git a/machines/macintosh.nix b/machines/macintosh.nix deleted file mode 100644 index e69de29..0000000 diff --git a/machines/newton.nix b/machines/newton.nix deleted file mode 100644 index e69de29..0000000