From a5a6a02929ef8222f516b4e03345d9fbb538285a Mon Sep 17 00:00:00 2001 From: Niten Date: Wed, 4 Aug 2021 12:37:55 -0700 Subject: [PATCH] Initial flake commit --- config/host-config/lambda.nix | 20 ++++----- config/host-config/zbox.nix | 4 +- config/profile-config/common-ui.nix | 7 ---- config/profile-config/server.nix | 11 +---- flake.nix | 18 +++++++-- home-manager/niten.nix | 29 +++++++------ lib/default.nix | 2 + lib/fudo/games/default.nix | 5 +++ lib/fudo/games/valheim.nix | 63 +++++++++++++++++++++++++++++ packages/default.nix | 9 ++++- 10 files changed, 122 insertions(+), 46 deletions(-) create mode 100644 lib/fudo/games/default.nix create mode 100644 lib/fudo/games/valheim.nix diff --git a/config/host-config/lambda.nix b/config/host-config/lambda.nix index 7a0fae0..48107b2 100644 --- a/config/host-config/lambda.nix +++ b/config/host-config/lambda.nix @@ -33,17 +33,17 @@ in { secret-paths = [ "/state/secrets" ]; }; - systemd.tmpfiles.rules = [ - "L /root/.gnupg - - - - ${state-dir}/user/root/gnupg" - # "L /root/.emacs.d - - - - ${state-dir}/user/root/emacs.d" - "L /root/.ssh/id_rsa - - - - ${state-dir}/user/root/ssh/id_rsa" - "L /root/.ssh/id_rsa.pub - - - - ${state-dir}/user/root/ssh/id_rsa.pub" - "L /root/.ssh/known_hosts - - - - ${state-dir}/user/root/ssh/known_hosts" + fudo.games.valheim = { + enable = true; + state-directory = "/state/games/valheim"; + password = "silkymilky"; + }; - # "L /etc/ssh/ssh_host_rsa_key - - - - ${state-dir}/ssh/ssh_host_rsa_key" - # "L /etc/ssh/ssh_host_rsa_key.pub - - - - ${state-dir}/ssh/ssh_host_rsa_key.pub" - # "L /etc/ssh/ssh_host_ed25519_key - - - - ${state-dir}/ssh/ssh_host_ed25519_key" - # "L /etc/ssh/ssh_host_ed25519_key.pub - - - - ${state-dir}/ssh/ssh_host_ed25519_key.pub" + systemd.tmpfiles.rules = [ + "L /root/.gnupg - - - - ${state-dir}/user/root/gnupg" + "L /root/.ssh/id_rsa - - - - ${state-dir}/user/root/ssh/id_rsa" + "L /root/.ssh/id_rsa.pub - - - - ${state-dir}/user/root/ssh/id_rsa.pub" + "L /root/.ssh/known_hosts - - - - ${state-dir}/user/root/ssh/known_hosts" ]; services.openssh.hostKeys = [ diff --git a/config/host-config/zbox.nix b/config/host-config/zbox.nix index a90ce5b..d26ad7c 100644 --- a/config/host-config/zbox.nix +++ b/config/host-config/zbox.nix @@ -2,7 +2,7 @@ { system.stateVersion = "20.09"; - + # TODO: remove? nixpkgs.config.permittedInsecurePackages = [ "openssh-with-gssapi-8.4p1" # CVE-2021-28041 @@ -10,6 +10,8 @@ fudo.slynk.enable = true; + environment.systemPackages = with pkgs; [ opencv-java worther ]; + networking = { interfaces = { eno1.useDHCP = false; diff --git a/config/profile-config/common-ui.nix b/config/profile-config/common-ui.nix index 2483112..9768419 100644 --- a/config/profile-config/common-ui.nix +++ b/config/profile-config/common-ui.nix @@ -43,13 +43,6 @@ in { # }; }; - emacs = { - enable = true; - install = true; - package = pkgs.emacs; - defaultEditor = true; - }; - trezord.enable = true; }; diff --git a/config/profile-config/server.nix b/config/profile-config/server.nix index 368fe7f..fca8406 100644 --- a/config/profile-config/server.nix +++ b/config/profile-config/server.nix @@ -52,16 +52,7 @@ in { networking.networkmanager.enable = mkForce false; - services = { - xserver.enable = false; - - emacs = { - enable = true; - install = true; - package = pkgs.emacs; - defaultEditor = true; - }; - }; + services = { xserver.enable = false; }; sound.enable = false; hardware.pulseaudio.enable = false; diff --git a/flake.nix b/flake.nix index 3535b7b..134d22a 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,7 @@ let target-version = "21.05"; in { - description = "A very basic flake"; + description = "Fudo Host Configuration"; inputs = { nixpkgs.url = "nixpkgs/nixos-${target-version}"; @@ -20,10 +20,20 @@ in { hosts = map hostname-from-file (attrNames (filterAttrs is-nix-file (filterAttrs is-regular-file (builtins.readDir ./config/hosts)))); - in { - nixConfigurations = mapAttrs (host: hostOpts: - lib.nixosSystem { + pkgs = import nixpkgs { }; + in { + nixConfigurations = mapAttrs (hostname: hostOpts: + lib.nixosSystem { + inherit system; + modules = [ + (import ./initialize.nix { + hostname = hostname; + home-manager-package = home-manager; + pkgs = pkgs; + include-secrets = true; + }) + ]; }) host-configs; }; } diff --git a/home-manager/niten.nix b/home-manager/niten.nix index 7132ed6..7503f0d 100644 --- a/home-manager/niten.nix +++ b/home-manager/niten.nix @@ -18,8 +18,8 @@ let doom-emacs = pkgs.callPackage (pkgs.fetchgit { url = "https://github.com/vlaci/nix-doom-emacs.git"; - rev = "3893c50877a9d2d5d4aeee524ba1539f22115f1f"; - sha256 = "1jz8mxh143a4470mq303ng6dh3bxi6mcppqli4z0m13qhqssh4fx"; + rev = "fee14d217b7a911aad507679dafbeaa8c1ebf5ff"; + sha256 = "1g0izscjh5nv4n0n1m58jc6z27i9pkbxs17mnb05a83ffdbmmva6"; }) { doomPrivateDir = "${pkgs.doom-emacs-config}"; extraPackages = with pkgs.emacsPackages; [ elpher use-package ]; @@ -70,6 +70,7 @@ let cdrtools cargo clojure + clj2nix cmake curl doom-emacs @@ -158,7 +159,17 @@ in { "Xft.lcdfilter" = "lcddefault"; }; - services.gpg-agent.enable = true; + services = { + emacs = { + enable = true; + package = doom-emacs; + client = { + enable = true; + arguments = [ "-t" ]; + }; + }; + gpg-agent.enable = true; + }; home = { packages = @@ -194,23 +205,15 @@ in { ''; }; - ".fonts.conf" = { source = ../static/fonts.conf; }; + # ".fonts.conf" = { source = ../static/fonts.conf; }; }; sessionVariables = { - EDITOR = "emacsclient -t"; + # EDITOR = "${doom-emacs}/bin/emacsclient -t"; ALTERNATE_EDITOR = ""; HISTCONTROL = "ignoredups:ignorespace"; }; - - # activation = let - # ensure-dir-script = dir: '' - # $DRY_RUN_CMD [[ -d "${dir}" ]] || mkdir -p "${dir}" - # ''; - # ensure-dirs-script = - # concatStringsSep "\n" (map ensure-dir-script ensure-directories); - # in hm.dag.entryAfter [ "writeBoundary" ] ensure-dirs-script; }; systemd.user.tmpfiles.rules = diff --git a/lib/default.nix b/lib/default.nix index e8f0f03..04e83ba 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -43,6 +43,8 @@ with lib; { ./fudo/webmail.nix ./fudo/wireless-networks.nix + ./fudo/games/valheim.nix + ./informis/cl-gemini.nix ]; } diff --git a/lib/fudo/games/default.nix b/lib/fudo/games/default.nix new file mode 100644 index 0000000..1858f1f --- /dev/null +++ b/lib/fudo/games/default.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + imports = [ ./valheim.nix ]; +} diff --git a/lib/fudo/games/valheim.nix b/lib/fudo/games/valheim.nix new file mode 100644 index 0000000..9c6d83f --- /dev/null +++ b/lib/fudo/games/valheim.nix @@ -0,0 +1,63 @@ +{ config, lib, pkgs, ... }: + +with lib; +let cfg = config.fudo.games.valheim; +in { + options.fudo.games.valheim = with types; { + enable = mkEnableOption "Enable dedicated Valheim server."; + + state-directory = mkOption { + type = str; + description = "Directory at which to store Valheim state data."; + default = "/var/lib/valheim"; + }; + + port = mkOption { + type = port; + description = "Port on which to listen for connections."; + default = 2456; + }; + + password = mkOption { + type = str; + description = "Password required by connecting users."; + }; + }; + + config = mkIf cfg.enable { + users.users.valheim = { + home = cfg.state-directory; + createHome = true; + isSystemUser = true; + }; + + systemd.services.fudo-valheim = { + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStartPre = '' + [[ -d ${cfg.state-directory}/state ]] || mkdir ${cfg.state-directory}/state + ${pkgs.steamcmd}/bin/steamcmd \ + +login anonymous \ + +force_install_dir ${cfg.state-directory}/state \ + +app_update 896660 \ + +quit + ''; + + ExecStart = '' + ${pkgs.glibc}/lib/ld-linux-x86-64.so.2 ./valheim_server.x86_64 \ + -name "CoCo Valheim" \ + -port ${toString cfg.port} \ + -world "Dedicated" \ + -password ${cfg.password} \ + -public 1 + ''; + Nice = -5; + Restart = "always"; + User = "valheim"; + StateDirectory = "${cfg.state-directory}/state"; + WorkingDirectory = cfg.state-directory; + }; + environment = { LD_LIBRARY_PATH = "linux64:${pkgs.glibc}/lib"; }; + }; + }; +} diff --git a/packages/default.nix b/packages/default.nix index 12aa5c0..d6870fc 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -68,8 +68,9 @@ in { opencv-java = pkgs.opencv.overrideAttrs (oldAttrs: rec { # buildInputs = oldAttrs.buildInputs ++ [ pkgs.ant ]; + pname = "opencv-java"; nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ pkgs.jdk11 pkgs.ant ]; - # cmakeFlags = oldAttrs.cmakeFlags ++ [ "-DWITH_JAVA=ON" ]; + cmakeFlags = oldAttrs.cmakeFlags ++ [ "-DWITH_JAVA=ON" ]; }); hll2380dw-cups = import ./hll2380dw-cups.nix { @@ -176,5 +177,11 @@ in { rev = "278a90f7ce219e36e5de0a80b540e469a9bce912"; sha256 = "06qns3ayc84mamdgn0jw652rvx60wy9km1vxm2361mzmx2zk89iw"; }; + + clj2nix = pkgs.callPackage (pkgs.fetchgit { + url = "https://github.com/hlolli/clj2nix.git"; + rev = "e6d09dd8c5cda68eb0534bd8501f2d5dcd7b2e95"; + sha256 = "0v0q6iglr0lx13j1snzd8mjxids1af1p2h7bkvmsyk2bfp36naqx"; + }) { }; }; }