From 9eb6609c7a6458fef468fc3dd5dab13f278c1a5f Mon Sep 17 00:00:00 2001 From: root Date: Sat, 6 Jun 2020 19:24:59 -0700 Subject: [PATCH] Changes on zbox.sea --- .gitignore | 2 + config/fudo/slynk.nix | 47 +++++++++++++++++++++++ config/local.nix | 1 + configuration.nix | 1 - defaults.nix | 5 +++ fudo/profiles/desktop.nix | 53 +++++++++++++++++++++----- hardware-configuration.nix | 31 --------------- hosts/zbox.nix | 76 ++++++++++++++++++++++++++++++------- lib/ip.nix | 56 +++++++++++++++++++++++++++ packages/hll2380dw-cups.nix | 40 +++++++++++++++++++ packages/local.nix | 15 ++++++-- 11 files changed, 269 insertions(+), 58 deletions(-) create mode 100644 .gitignore create mode 100644 config/fudo/slynk.nix delete mode 120000 configuration.nix delete mode 100644 hardware-configuration.nix create mode 100644 lib/ip.nix create mode 100644 packages/hll2380dw-cups.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2ee4098 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +configuration.nix +hardware-configuration.nix diff --git a/config/fudo/slynk.nix b/config/fudo/slynk.nix new file mode 100644 index 0000000..a8efe2a --- /dev/null +++ b/config/fudo/slynk.nix @@ -0,0 +1,47 @@ +{ config, lib, pkgs, ... }: + +with lib; +let + cfg = config.fudo.slynk; + + initScript = port: pkgs.writeText "slynk.lisp" '' + (load (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))) + (ql:quickload :slynk) + (slynk:create-server :port ${toString port} :dont-close t) + (dolist (var '("LD_LIBRARY_PATH")) + (format t "~S: ~S~%" var (sb-unix::posix-getenv var))) + + (loop (sleep 60)) + ''; + +in { + options.fudo.slynk = { + enable = mkEnableOption "Enable Slynk emacs common lisp server."; + + port = mkOption { + type = types.int; + description = "Port on which to open a Slynk server."; + default = 4005; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.slynk = { + description = "Slynk Common Lisp server."; + + serviceConfig = { + # Type = "simple"; + ExecStartPre = "${pkgs.lispPackages.quicklisp}/bin/quicklisp init"; + ExecStart = "${pkgs.sbcl-with-libs}/bin/sbcl --load ${initScript cfg.port}"; + Restart = "on-failure"; + PIDFile = "/run/slynk.$USERNAME.pid"; + }; + + environment = { + LD_LIBRARY_PATH = "${pkgs.openssl_1_1.out}/lib:${pkgs.libuv.out}/lib"; + }; + + wantedBy = [ "default.target" ]; + }; + }; +} diff --git a/config/local.nix b/config/local.nix index 0e3b01f..397fa3e 100644 --- a/config/local.nix +++ b/config/local.nix @@ -18,6 +18,7 @@ with lib; ./fudo/postgres.nix ./fudo/prometheus.nix ./fudo/system.nix + ./fudo/slynk.nix ./fudo/webmail.nix ../fudo/profiles diff --git a/configuration.nix b/configuration.nix deleted file mode 120000 index 4de3171..0000000 --- a/configuration.nix +++ /dev/null @@ -1 +0,0 @@ -./hosts/france.nix \ No newline at end of file diff --git a/defaults.nix b/defaults.nix index fa03dcd..030d694 100644 --- a/defaults.nix +++ b/defaults.nix @@ -18,6 +18,7 @@ autoconf automake bash + boot bind binutils btrfs-progs @@ -28,6 +29,7 @@ certbot clang curl + dpkg emacs fail2ban fortune @@ -44,6 +46,7 @@ jdk kerberos libisofs + libstdcxxHook lispPackages.alexandria lispPackages.cl-ppcre lispPackages.clx @@ -64,6 +67,7 @@ ruby rustc sbcl + sbclBootstrap screen service-wrapper stdenv @@ -73,6 +77,7 @@ unzip vim wget + yubikey-manager ]; system.stateVersion = "19.09"; diff --git a/fudo/profiles/desktop.nix b/fudo/profiles/desktop.nix index 302fcc9..ea1460f 100644 --- a/fudo/profiles/desktop.nix +++ b/fudo/profiles/desktop.nix @@ -5,8 +5,10 @@ with lib; config = mkIf (config.fudo.common.profile == "desktop") { environment.systemPackages = with pkgs; [ cool-retro-term + corefonts chrome-gnome-shell chromium + evince ffmpeg-full firefox gimp @@ -20,16 +22,44 @@ with lib; gtkimageview i3lock libfixposix - minecraft + minecraft-current + mono mplayer + mpv nomacs openssl_1_1 + pdftk + python37Packages.youtube-dl redshift rhythmbox shotwell spotify sqlite - steam + (steam.override { + nativeOnly = true; + extraPkgs = pkgs: [ + mono + gtk3 + gtk3-x11 + libgdiplus + zlib + ]; + withJava = true; + }) + (steam.override { + nativeOnly = true; + extraPkgs = pkgs: [ + mono + fmodex + gtk3 + gtk3-x11 + libgdiplus + zlib + ]; + withJava = true; + }).run + # steam-run + # steam-run-native system-config-printer virtmanager xorg.xev @@ -37,13 +67,15 @@ with lib; virtmanager-qt ]; + nixpkgs.config.allowBroken = true; + # Splash screen boot.plymouth.enable = true; services.avahi = { enable = true; - browseDomains = [config.fudo.domain]; - domainName = config.fudo.domain; + browseDomains = [config.fudo.common.domain]; + domainName = config.fudo.common.domain; }; boot.tmpOnTmpfs = true; @@ -56,16 +88,17 @@ with lib; xkbOptions = "ctrl:nocaps"; desktopManager.gnome3.enable = true; - desktopManager.default = "gnome3"; displayManager.gdm.enable = true; + displayManager.defaultSession = "gnome"; + windowManager.session = pkgs.lib.singleton { name = "stumpwm"; start = '' ${pkgs.lispPackages.stumpwm}/bin/stumpwm & - waidPID=$! - ''; + waidPID=$! + ''; }; }; @@ -89,10 +122,12 @@ with lib; hardware.pulseaudio.enable = true; fonts = { - enableCoreFonts = true; enableFontDir = true; enableGhostscriptFonts = false; - fontconfig.ultimate.enable = true; + fontconfig.antialias = true; + fontconfig.enable = true; + fontconfig.penultimate.enable = true; + fontconfig.subpixel.lcdfilter = "default"; fonts = with pkgs; [ cantarell_fonts diff --git a/hardware-configuration.nix b/hardware-configuration.nix deleted file mode 100644 index e6d1fe0..0000000 --- a/hardware-configuration.nix +++ /dev/null @@ -1,31 +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, ... }: - -{ - imports = - [ - ]; - - boot.initrd.availableKernelModules = [ "uhci_hcd" "ehci_pci" "ata_piix" "ahci" "usb_storage" "floppy" "sd_mod" "sr_mod" ]; - boot.initrd.kernelModules = [ "dm-snapshot" ]; - boot.kernelModules = [ "kvm-intel" ]; - boot.extraModulePackages = [ ]; - - fileSystems."/" = - { device = "/dev/disk/by-uuid/87833c39-299b-4e84-9854-beda4a8e0115"; - fsType = "ext4"; - }; - - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/bfb464c0-c259-4c29-8e8f-b3011bd30c95"; - fsType = "ext4"; - }; - - swapDevices = - [ { device = "/dev/disk/by-uuid/ac0fe2b7-dd7a-4e86-aaa0-942acf3d541d"; } - ]; - - nix.maxJobs = lib.mkDefault 8; -} diff --git a/hosts/zbox.nix b/hosts/zbox.nix index eb74542..5c16ba2 100644 --- a/hosts/zbox.nix +++ b/hosts/zbox.nix @@ -4,34 +4,84 @@ let hostname = "zbox"; in { - imports = [ - ../defaults.nix - ../networks/sea.fudo.org.nix - ../profiles/desktop.nix - ../hardware-configuration.nix - ]; - - environment.systemPackages = with pkgs; [ - glxinfo - ]; # Use the systemd-boot EFI boot loader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; + imports = [ + ../defaults.nix + ../hardware-configuration.nix + ]; + + environment.systemPackages = with pkgs; [ + androidenv.androidPkgs_9_0.platform-tools + android-studio + glxinfo + hll2380dw-cups + nodejs + signal-desktop + usbutils + ]; + + fudo.common = { + profile = "desktop"; + site = "seattle"; + }; + + fudo.slynk = { + enable = true; + }; + hardware.cpu.intel.updateMicrocode = true; - programs.bash.enableCompletion = true; + programs = { + adb.enable = true; + bash.enableCompletion = true; + }; services.xserver = { videoDrivers = ["nvidia"]; - displayManager.gdm.wayland = false; + # displayManager.gdm.wayland = false; }; hardware.opengl.driSupport32Bit = true; + hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ]; hardware.opengl.driSupport = true; - networking.hostName = hostname; + hardware.pulseaudio.support32Bit = true; + + networking = { + hostName = hostname; + + macvlans = { + intif0 = { + interface = "eno1"; + mode = "bridge"; + }; + }; + + interfaces = { + eno1.useDHCP = false; + intif0 = { + macAddress = "02:dd:80:52:83:9b"; + useDHCP = false; + ipv4.addresses = [ + { + address = "10.0.0.110"; + prefixLength = 24; + } + ]; + }; + }; + }; hardware.bluetooth.enable = true; + + users.users.niten = { + extraGroups = ["adbusers"]; + }; + + virtualisation.lxd.enable = true; + } diff --git a/lib/ip.nix b/lib/ip.nix new file mode 100644 index 0000000..7f55bf0 --- /dev/null +++ b/lib/ip.nix @@ -0,0 +1,56 @@ +{ lib }: + +with lib; +let + joinString = lib.concatStringsSep; + + pow = x: e: if (e == 0) then 1 else x * (pow x (e - 1)); + +in rec { + + generateNBits = n: let + helper = n: c: if (c == n) then pow 2 c else (pow 2 c) + (helper n (c + 1)); + in if (n <= 0) then throw "Can't generate 0 or fewer bits" else helper (n - 1) 0; + + reverseIpv4 = ip: joinString "." (reverseList (splitString "." ip)); + + intToBinaryList = int: let + helper = int: cur: let + curExp = pow 2 cur; + in if (curExp > int) then + [] + else + [(if ((bitAnd curExp int) > 0) then 1 else 0)] ++ (helper int (cur + 1)); + in reverseList (helper int 0); + + leftShift = int: n: int * (pow 2 n); + + rightShift = int: n: int / (pow 2 n); + + ipv4ToInt = ip: let + els = map toInt (reverseList (splitString "." ip)); + in foldr (a: b: a + b) 0 (imap0 (i: el: (leftShift el (i * 8))) els); + + intToIpv4 = int: joinString "." (map (i: toString (bitAnd (rightShift int (i * 8)) 255)) [ 3 2 1 0 ]); + + rightPadBits = int: bits: bitOr int (generateNBits bits); + + maskFromV32Network = network: let + fullMask = ipv4ToInt "255.255.255.255"; + insignificantBits = 32 - (getNetworkMask network); + in intToIpv4 (leftShift (rightShift fullMask insignificantBits) insignificantBits); + + getNetworkMask = network: toInt (elemAt (splitString "/" network) 1); + + getNetworkBase = network: let + ip = elemAt (splitString "/" network) 0; + insignificantBits = 32 - (getNetworkMask network); + in intToIpv4 (leftShift (rightShift (ipv4ToInt ip) insignificantBits) insignificantBits); + + networkMinIp = network: intToIpv4 (1 + (ipv4ToInt (getNetworkBase network))); + + networkMaxIp = network: intToIpv4 (rightPadBits (ipv4ToInt (getNetworkBase network)) (32 - (getNetworkMask network))); + + # To avoid broadcast IP... + networkMaxButOneIp = network: intToIpv4 ((rightPadBits (ipv4ToInt (getNetworkBase network)) (32 - (getNetworkMask network))) - 1); +} diff --git a/packages/hll2380dw-cups.nix b/packages/hll2380dw-cups.nix new file mode 100644 index 0000000..b0ed6dd --- /dev/null +++ b/packages/hll2380dw-cups.nix @@ -0,0 +1,40 @@ +{ stdenv, fetchurl, makeWrapper, cups, dpkg, a2ps, ghostscript, gnugrep, gnused, coreutils, file, perl, which }: + +stdenv.mkDerivation rec { + pname = "hll2380dw-cups"; + version = "3.2.0-1"; + platform = "i386"; + + src = fetchurl { + url = "https://download.brother.com/welcome/dlf101772/hll2380dwcupswrapper-${version}.i386.deb"; + sha256 = "08g3kx5lgwzb3f9ypj8knmpkkj0h3kv1i4gd20rzjxrx6vx1wbpl"; + }; + + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ cups ghostscript dpkg a2ps ]; + + dontUnpack = true; + + installPhase = '' + dpkg-deb -x $src $out + wrapProgram $out/opt/brother/Printers/HLL2380DW/cupswrapper/paperconfigml1 \ + --prefix PATH : ${stdenv.lib.makeBinPath [ + coreutils ghostscript gnugrep gnused + ]} + mkdir -p $out/lib/cups/filter/ + ln -s $out/opt/brother/Printers/HLL2380DW/cupswrapper/brother_lpdwrapper_HLL2380W \ + $out/lib/cups/filter/brother_lpdwrapper_HLL2380DW + ln -s $out/opt/brother/Printers/HLL2380DW/paperconfigml1 \ + $out/lib/cups/filter/ + mkdir -p $out/share/cups/model + ln -s $out/opt/brother/Printers/HLL2380DW/cupswrapper/brother-HLL2380DW-cups-en.ppd $out/share/cups/model/ + ''; + + meta = with stdenv.lib; { + homepage = http://www.brother.com/; + description = "Brother HL-L2380DW combined print driver"; + license = licenses.unfree; + platforms = [ "x86_64-linux" ]; + downloadPage = http://support.brother.com/g/b/downloadlist.aspx?c=us_ot&lang=en&prod=hll2380dw_us&os=128; + }; +} diff --git a/packages/local.nix b/packages/local.nix index 1e6174c..fc00911 100644 --- a/packages/local.nix +++ b/packages/local.nix @@ -15,22 +15,29 @@ }; }); - minecraft-server_1_15_2 = pkgs.minecraft-server.overrideAttrs (oldAttrs: rec { - version = "1.15.2"; + minecraft-current = pkgs.minecraft.overrideAttrs (oldAttrs: rec { src = builtins.fetchurl { - url = "https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar"; - sha256 = "12kynrpxgcdg8x12wcvwkxka0fxgm5siqg8qq0nnmv0443f8dkw0"; + url = "https://launcher.mojang.com/download/Minecraft.tar.gz"; + sha256 = "1k9gf1v1law4kiz8f7i2fxkj5vq2cm37b3ys95zpyf4aiw5nzg33"; }; }); postgresql_11_gssapi = pkgs.postgresql_11.overrideAttrs (oldAttrs: rec { configureFlags = oldAttrs.configureFlags ++ [ "--with-gssapi" ]; buildInputs = oldAttrs.buildInputs ++ [ pkgs.krb5 ]; + sbcl-with-libs = pkgs.sbcl.overrideAttrs (oldAttrs: rec { + extraLibs = with pkgs; [ + openssl_1_1.dev + ]; }); postgresql_12_gssapi = pkgs.postgresql_12.overrideAttrs (oldAttrs: rec { configureFlags = oldAttrs.configureFlags ++ [ "--with-gssapi" ]; buildInputs = oldAttrs.buildInputs ++ [ pkgs.krb5 ]; }); + + hll2380dw-cups = import ./hll2380dw-cups.nix { + inherit (pkgs) stdenv fetchurl makeWrapper cups dpkg a2ps ghostscript gnugrep gnused coreutils file perl which; + }; }; }