nixos

NixOS server files. Mirror from https://git.nordgedanken.dev/kubernetes/nixos
git clone git://archive.git.mtrnord.blog/MTRNord/nixos.git
Log | Files | Refs | README

commit c33fbe738c09e4fa8197b020837ce02afe46a7eb
parent 29a1b6d2cc31d1a802b11158fc36e4fddea6ddab
Author: MTRNord <mtrnord1@gmail.com>
Date:   Tue,  8 Aug 2023 20:36:23 +0200

Set up git, setup networking a little, setup timezone, install some packages

Diffstat:
MTODOs.md | 3++-
Mflake.lock | 39+++++++++++++++++++++++++++++++++++++++
Mflake.nix | 33+++++++++++++++++++++++++--------
Mhome-manager/home.nix | 6+++++-
Mnixos/worker-1/configuration.nix | 40+++++++++++++++++++++++++++++++++++++---
5 files changed, 108 insertions(+), 13 deletions(-)

diff --git a/TODOs.md b/TODOs.md @@ -1 +1,2 @@ -- Setup server age via https://github.com/Mic92/sops-nix -> Step 3 +- Setup server age via <https://github.com/Mic92/sops-nix> -> Step 3 +- Make reusable stuff reusable (Timezone, users, ...) diff --git a/flake.lock b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1691475627, + "narHash": "sha256-aOgYmNqXyCHw1vaNDv5GqUAURiPMVej4xQNE37bCF8g=", + "owner": "nix-community", + "repo": "fenix", + "rev": "72b64bd857cacd2733ce99fbf0603bbe335d357c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "hardware": { "locked": { "lastModified": 1691305349, @@ -102,6 +123,7 @@ }, "root": { "inputs": { + "fenix": "fenix", "hardware": "hardware", "home-manager": "home-manager", "nixpkgs": "nixpkgs", @@ -109,6 +131,23 @@ "sops-nix": "sops-nix" } }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1691410619, + "narHash": "sha256-npJ8zOZ/CQoZu+0kN5NU9iC5JbmbsucyK1DayPmHWPs=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "d9e9ca29814e95bb40db2216ed0973d9ba54b6a2", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, "sops-nix": { "inputs": { "nixpkgs": "nixpkgs_2", diff --git a/flake.nix b/flake.nix @@ -19,25 +19,31 @@ # Shameless plug: looking for a way to nixify your themes and make # everything match nicely? Try nix-colors! # nix-colors.url = "github:misterio77/nix-colors"; + + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, home-manager, sops-nix, ... }@inputs: + outputs = { self, fenix, nixpkgs, home-manager, sops-nix, ... }@inputs: let inherit (self) outputs; forAllSystems = nixpkgs.lib.genAttrs [ "aarch64-linux" - "i686-linux" "x86_64-linux" - "aarch64-darwin" - "x86_64-darwin" ]; in rec { # Your custom packages # Acessible through 'nix build', 'nix shell', etc packages = forAllSystems (system: - let pkgs = nixpkgs.legacyPackages.${system}; - in import ./pkgs { inherit pkgs; } + let + pkgs = nixpkgs.legacyPackages.${system}; + x86_64-linux.default = fenix.packages.x86_64-linux.stable.toolchain; + aarch64-linux.default = fenix.packages.aarch64-linux.stable.toolchain; + in + import ./pkgs { inherit pkgs; } ); # Devshell for bootstrapping # Acessible through 'nix develop' or 'nix-shell' (legacy) @@ -62,13 +68,25 @@ # NixOS configuration entrypoint # Available through 'nixos-rebuild --flake .#your-hostname' nixosConfigurations = { - # FIXME replace with your hostname worker-1 = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs outputs; }; modules = [ # > Our main nixos configuration file < ./nixos/worker-1/configuration.nix sops-nix.nixosModules.sops + ({ pkgs, ... }: { + nixpkgs.overlays = [ fenix.overlays.default ]; + environment.systemPackages = with pkgs; [ + (fenix.complete.withComponents [ + "cargo" + "clippy" + "rust-src" + "rustc" + "rustfmt" + ]) + rust-analyzer-nightly + ]; + }) ]; }; }; @@ -76,7 +94,6 @@ # Standalone home-manager configuration entrypoint # Available through 'home-manager --flake .#your-username@your-hostname' homeConfigurations = { - # FIXME replace with your username@hostname "marcel@worker-1" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance extraSpecialArgs = { inherit inputs outputs; }; diff --git a/home-manager/home.nix b/home-manager/home.nix @@ -52,7 +52,11 @@ # Enable home-manager and git programs.home-manager.enable = true; - programs.git.enable = true; + programs.git = { + enable = true; + userName = "MTRNord"; + userEmail = "support@nordgedanken.dev"; + }; # Nicely reload system units when changing configs systemd.user.startServices = "sd-switch"; diff --git a/nixos/worker-1/configuration.nix b/nixos/worker-1/configuration.nix @@ -60,13 +60,47 @@ }; }; + # General stuff + time.timeZone = "Europe/Berlin"; + # btrfs boot boot.kernelPackages = pkgs.linuxPackages_latest; boot.supportedFilesystems = [ "btrfs" ]; hardware.enableAllFirmware = true; - networking.hostName = "worker-1"; - networking.networkmanager.enable = true; + networking = { + hostName = "worker-1"; + # networkmanager.enable = true; + + # Open ports in the firewall. + firewall = { + enable = true; + allowedTCPPorts = [ + 22 # ssh + ]; + allowedUDPPorts = [ ]; + }; + }; + + # packages that are not flakes + environment.systemPackages = with pkgs; [ + wget + curl + htop + lsof + tree + unzip + unar + git + ripgrep + clang + llvm + gcc + binutils + file + go + dos2unix + ]; boot.loader = { systemd-boot = { @@ -74,7 +108,7 @@ configurationLimit = 10; editor = false; }; - efi.canTouchEfiVariables = false; + efi.canTouchEfiVariables = true; }; # TODO: Fix boot.kernelParams = [ "ip=95.217.202.35/26 gk.net.gw=95.217.202.1 gk.net.iface=a8:a1:59:0f:23:1f" ];