From 1fb49e2b8bbde800bbdcc8057204357bedaf96ac Mon Sep 17 00:00:00 2001 From: Grigory Shipunov Date: Wed, 24 Aug 2022 18:48:33 +0200 Subject: [PATCH] nixpkgs-fmt --- flake.nix | 11 +++-- hardware/dell-wyse-3040.nix | 4 +- hardware/rpi-3b-4b.nix | 68 +++++++++++++------------- hosts/data-hoarder/configuration.nix | 6 +-- hosts/traffic-stop-box/default.nix | 12 ++--- modules/data-hoarder/dvb-api.nix | 3 +- modules/data-hoarder/secrets.nix | 2 +- modules/data-hoarder/socket.nix | 5 +- modules/dump-dvb/general-options.nix | 10 ++-- modules/make-disk-image.nix | 59 ++++++++++++----------- modules/mobile-box/dresden.nix | 72 ++++++++++++++-------------- 11 files changed, 132 insertions(+), 120 deletions(-) diff --git a/flake.nix b/flake.nix index c281c5e..c85581f 100644 --- a/flake.nix +++ b/flake.nix @@ -82,7 +82,8 @@ ); id_list = [ - { # Barkhausen Bau + { + # Barkhausen Bau id = 0; arch = "x86_64-linux"; extraModules = [ @@ -90,7 +91,8 @@ diskModule ]; } - { # Zentralwerk + { + # Zentralwerk id = 1; arch = "x86_64-linux"; extraModules = [ @@ -98,7 +100,8 @@ diskModule ]; } - { # Chemnitz + { + # Chemnitz id = 2; arch = "x86_64-linux"; extraModules = [ @@ -186,5 +189,5 @@ mobile-box-disk."x86_64-linux" = self.nixosConfigurations.mobile-box.config.system.build.diskImage; sops-binaries."x86_64-linux" = sops-nix.packages."x86_64-linux".sops-install-secrets; }; - }; + }; } diff --git a/hardware/dell-wyse-3040.nix b/hardware/dell-wyse-3040.nix index b2e61b1..e3de3f7 100644 --- a/hardware/dell-wyse-3040.nix +++ b/hardware/dell-wyse-3040.nix @@ -8,8 +8,8 @@ networking.interfaces.enp1s0.useDHCP = true; boot.tmpOnTmpfsSize = "25%"; - boot.kernelModules = [ "kvm-intel" ]; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + boot.kernelModules = [ "kvm-intel" ]; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; boot.loader.systemd-boot.configurationLimit = 1; diff --git a/hardware/rpi-3b-4b.nix b/hardware/rpi-3b-4b.nix index eecc923..a3a7473 100644 --- a/hardware/rpi-3b-4b.nix +++ b/hardware/rpi-3b-4b.nix @@ -9,47 +9,49 @@ networking.interfaces.eth0.useDHCP = true; sdImage = lib.mkForce { - populateFirmwareCommands = let - configTxt = pkgs.writeText "config.txt" '' - [pi3] - kernel=u-boot-rpi3.bin - hdmi_force_hotplug=1 + populateFirmwareCommands = + let + configTxt = pkgs.writeText "config.txt" '' + [pi3] + kernel=u-boot-rpi3.bin + hdmi_force_hotplug=1 - [pi02] - kernel=u-boot-rpi3.bin + [pi02] + kernel=u-boot-rpi3.bin - [pi4] - kernel=u-boot-rpi4.bin - enable_gic=1 - armstub=armstub8-gic.bin + [pi4] + kernel=u-boot-rpi4.bin + enable_gic=1 + armstub=armstub8-gic.bin - # Otherwise the resolution will be weird in most cases, compared to - # what the pi3 firmware does by default. - disable_overscan=1 + # Otherwise the resolution will be weird in most cases, compared to + # what the pi3 firmware does by default. + disable_overscan=1 - # Supported in newer board revisions - arm_boost=1 + # Supported in newer board revisions + arm_boost=1 - [cm4] - # Enable host mode on the 2711 built-in XHCI USB controller. - # This line should be removed if the legacy DWC2 controller is required - # (e.g. for USB device mode) or if USB support is not required. - otg_mode=1 + [cm4] + # Enable host mode on the 2711 built-in XHCI USB controller. + # This line should be removed if the legacy DWC2 controller is required + # (e.g. for USB device mode) or if USB support is not required. + otg_mode=1 - [all] - # Boot in 64-bit mode. - arm_64bit=1 + [all] + # Boot in 64-bit mode. + arm_64bit=1 - # U-Boot needs this to work, regardless of whether UART is actually used or not. - # Look in arch/arm/mach-bcm283x/Kconfig in the U-Boot tree to see if this is still - # a requirement in the future. - enable_uart=1 + # U-Boot needs this to work, regardless of whether UART is actually used or not. + # Look in arch/arm/mach-bcm283x/Kconfig in the U-Boot tree to see if this is still + # a requirement in the future. + enable_uart=1 - # Prevent the firmware from smashing the framebuffer setup done by the mainline kernel - # when attempting to show low-voltage or overtemperature warnings. - avoid_warnings=1 - ''; - in '' + # Prevent the firmware from smashing the framebuffer setup done by the mainline kernel + # when attempting to show low-voltage or overtemperature warnings. + avoid_warnings=1 + ''; + in + '' (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/firmware/) # Add the config diff --git a/hosts/data-hoarder/configuration.nix b/hosts/data-hoarder/configuration.nix index cb651da..2e9fb1d 100644 --- a/hosts/data-hoarder/configuration.nix +++ b/hosts/data-hoarder/configuration.nix @@ -7,11 +7,11 @@ hypervisor = "cloud-hypervisor"; mem = 4096; vcpu = 8; - interfaces = [ { + interfaces = [{ type = "tap"; id = "serv-dvb-prod"; mac = "02:db:db:db:db:db"; - } ]; + }]; shares = [ { source = "/nix/store"; @@ -26,7 +26,7 @@ tag = "etc"; proto = "virtiofs"; socket = "etc.socket"; - } + } { source = "/var/lib/microvms/data-hoarder/var"; mountPoint = "/var"; diff --git a/hosts/traffic-stop-box/default.nix b/hosts/traffic-stop-box/default.nix index 8003643..fb1b2d2 100644 --- a/hosts/traffic-stop-box/default.nix +++ b/hosts/traffic-stop-box/default.nix @@ -1,9 +1,9 @@ { imports = [ - ./configuration.nix - ./hardware-configuration.nix - ./radio-config.nix - ./secrets.nix - ./wireguard-client.nix -]; + ./configuration.nix + ./hardware-configuration.nix + ./radio-config.nix + ./secrets.nix + ./wireguard-client.nix + ]; } diff --git a/modules/data-hoarder/dvb-api.nix b/modules/data-hoarder/dvb-api.nix index 2d24ce3..ef79e84 100644 --- a/modules/data-hoarder/dvb-api.nix +++ b/modules/data-hoarder/dvb-api.nix @@ -1,7 +1,8 @@ { config, ... }: let service_number = 1; -in { +in +{ dump-dvb.api = { enable = true; GRPC = { diff --git a/modules/data-hoarder/secrets.nix b/modules/data-hoarder/secrets.nix index b2dd793..8d274dd 100644 --- a/modules/data-hoarder/secrets.nix +++ b/modules/data-hoarder/secrets.nix @@ -1,4 +1,4 @@ -{ config, ... }: +{ config, ... }: let clicky-bunty-user = config.dump-dvb.clickyBuntyServer.user; data-accumulator-user = config.dump-dvb.dataAccumulator.user; diff --git a/modules/data-hoarder/socket.nix b/modules/data-hoarder/socket.nix index dc573b4..9042dcb 100644 --- a/modules/data-hoarder/socket.nix +++ b/modules/data-hoarder/socket.nix @@ -1,7 +1,8 @@ -{ config, ... }: +{ config, ... }: let serice_number = 2; -in { +in +{ dump-dvb.funnel = { enable = true; GRPC = { diff --git a/modules/dump-dvb/general-options.nix b/modules/dump-dvb/general-options.nix index 5d00d2c..d32c28c 100644 --- a/modules/dump-dvb/general-options.nix +++ b/modules/dump-dvb/general-options.nix @@ -7,12 +7,12 @@ with lib; { description = "number of the system"; }; - dump-dvb.domain = mkOption { - type = types.str; - default = "dvb.solutions"; - description = "domain the server is running on"; + dump-dvb.domain = mkOption { + type = types.str; + default = "dvb.solutions"; + description = "domain the server is running on"; + }; }; -}; } diff --git a/modules/make-disk-image.nix b/modules/make-disk-image.nix index 545051c..9952bd3 100644 --- a/modules/make-disk-image.nix +++ b/modules/make-disk-image.nix @@ -27,7 +27,7 @@ # user and group name that will be set as owner of the files. # `mode', `user', and `group' are optional. # When setting one of `user' or `group', the other needs to be set too. - contents ? [] + contents ? [ ] , # Type of partition table to use; either "legacy", "efi", or "none". # For "efi" images, the GPT partition table is used and a mandatory ESP @@ -77,7 +77,7 @@ copyChannel ? true , # Additional store paths to copy to the image's store. - additionalPaths ? [] + additionalPaths ? [ ] }: assert partitionTableType == "legacy" || partitionTableType == "legacy+gpt" || partitionTableType == "efi" || partitionTableType == "hybrid" || partitionTableType == "none"; @@ -85,10 +85,10 @@ assert partitionTableType == "legacy" || partitionTableType == "legacy+gpt" || p assert partitionTableType != "none" -> fsType == "ext4"; # Either both or none of {user,group} need to be set assert lib.all - (attrs: ((attrs.user or null) == null) - == ((attrs.group or null) == null)) - contents; -assert onlyNixStore -> contents == [] && configFile == null && !installBootLoader; + (attrs: ((attrs.user or null) == null) + == ((attrs.group or null) == null)) + contents; +assert onlyNixStore -> contents == [ ] && configFile == null && !installBootLoader; with lib; @@ -100,19 +100,21 @@ let format' = format; in let filename = "nixos." + { qcow2 = "qcow2"; - vdi = "vdi"; - vpc = "vhd"; - raw = "img"; + vdi = "vdi"; + vpc = "vhd"; + raw = "img"; }.${format} or format; - rootPartition = { # switch-case + rootPartition = { + # switch-case legacy = "1"; "legacy+gpt" = "2"; efi = "2"; hybrid = "3"; }.${partitionTableType}; - partitionDiskScript = { # switch-case + partitionDiskScript = { + # switch-case legacy = '' parted --script $diskImage -- \ mklabel msdos \ @@ -150,7 +152,7 @@ let format' = format; in let nixpkgs = cleanSource pkgs.path; # FIXME: merge with channel.nix / make-channel.nix. - channelSources = pkgs.runCommand "nixos-${config.system.nixos.version}" {} '' + channelSources = pkgs.runCommand "nixos-${config.system.nixos.version}" { } '' mkdir -p $out cp -prd ${nixpkgs.outPath} $out/nixos chmod -R u+w $out/nixos @@ -162,7 +164,8 @@ let format' = format; in let ''; binPath = with pkgs; makeBinPath ( - [ rsync + [ + rsync util-linux parted e2fsprogs @@ -171,16 +174,17 @@ let format' = format; in let config.system.build.nixos-enter nix systemdMinimal - ] ++ stdenv.initialPath); + ] ++ stdenv.initialPath + ); # I'm preserving the line below because I'm going to search for it across nixpkgs to consolidate # image building logic. The comment right below this now appears in 4 different places in nixpkgs :) # !!! should use XML. sources = map (x: x.source) contents; targets = map (x: x.target) contents; - modes = map (x: x.mode or "''") contents; - users = map (x: x.user or "''") contents; - groups = map (x: x.group or "''") contents; + modes = map (x: x.mode or "''") contents; + users = map (x: x.user or "''") contents; + groups = map (x: x.group or "''") contents; basePaths = [ config.system.build.toplevel ] ++ lib.optional copyChannel channelSources; @@ -373,12 +377,13 @@ let format' = format; in let ''; buildImage = pkgs.vmTools.runInLinuxVM ( - pkgs.runCommand name { - preVM = prepareImage; - buildInputs = with pkgs; [ util-linux e2fsprogs dosfstools ]; - postVM = moveOrConvertImage + postVM; - memSize = 1024; - } '' + pkgs.runCommand name + { + preVM = prepareImage; + buildInputs = with pkgs; [ util-linux e2fsprogs dosfstools ]; + postVM = moveOrConvertImage + postVM; + memSize = 1024; + } '' export PATH=${binPath}:$PATH rootDisk=${if partitionTableType != "none" then "/dev/vda${rootPartition}" else "/dev/vda"} @@ -442,7 +447,7 @@ let format' = format; in let '' ); in - if onlyNixStore then - pkgs.runCommand name {} - (prepareImage + moveOrConvertImage + postVM) - else buildImage +if onlyNixStore then + pkgs.runCommand name { } + (prepareImage + moveOrConvertImage + postVM) +else buildImage diff --git a/modules/mobile-box/dresden.nix b/modules/mobile-box/dresden.nix index e46ae79..57f5579 100644 --- a/modules/mobile-box/dresden.nix +++ b/modules/mobile-box/dresden.nix @@ -1,39 +1,39 @@ { pkgs, config, ... }: - { - dump-dvb = { - gnuradio = { - enable = true; - device = ""; - frequency = 170795000; - offset = 19550; - RF = 14; - IF = 32; - BB = 42; - }; - telegramDecoder = { - enable = true; - server = [ "http://127.0.0.1:8080" ]; - offline = true; - }; - dataAccumulator = { - enable = true; - host = "0.0.0.0"; - port = 8080; - DB.backend = "CSVFILE"; - R09CsvFile = "/var/lib/data-accumulator/formatted.csv"; - offline = true; - }; +{ + dump-dvb = { + gnuradio = { + enable = true; + device = ""; + frequency = 170795000; + offset = 19550; + RF = 14; + IF = 32; + BB = 42; }; - networking.firewall.allowedTCPPorts = [ 80 config.dump-dvb.wartrammer.port ]; - dump-dvb.wartrammer.enable = true; - systemd.services."start-wifi-hotspot" = { - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - Type = "simple"; - }; - script = '' - ${pkgs.linux-router}/bin/lnxrouter --ap wlp0s20u2 dump-dvb -g 10.3.141.1 -p trolling-dvb - ''; - }; + telegramDecoder = { + enable = true; + server = [ "http://127.0.0.1:8080" ]; + offline = true; + }; + dataAccumulator = { + enable = true; + host = "0.0.0.0"; + port = 8080; + DB.backend = "CSVFILE"; + R09CsvFile = "/var/lib/data-accumulator/formatted.csv"; + offline = true; + }; + }; + networking.firewall.allowedTCPPorts = [ 80 config.dump-dvb.wartrammer.port ]; + dump-dvb.wartrammer.enable = true; + systemd.services."start-wifi-hotspot" = { + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "simple"; + }; + script = '' + ${pkgs.linux-router}/bin/lnxrouter --ap wlp0s20u2 dump-dvb -g 10.3.141.1 -p trolling-dvb + ''; + }; - } +}