~euandreh/dotfiles

f5ff47868b2e62bbdba2dc868b869f3e72481d01 — EuAndreh 11 months ago 34bb9a1
Format Nix files with newer nixfmt
M default.nix => default.nix +1 -1
@@ 21,5 21,5 @@ in rec {
    (utils.fixme [ "default.nix" "utils.nix" ])
  ];
  publishScript =
  utils.overwritingPublishScript { docsDerivation = subtasks.docs; };
    utils.overwritingPublishScript { docsDerivation = subtasks.docs; };
}

M nixos/common.nix => nixos/common.nix +4 -4
@@ 2,18 2,18 @@
  cron = {
    # Sync emails with mbsync every hour
    mail =
    "0 * * * * andreh /home/andreh/dev/libre/dotfiles/scripts/cron/sync-mail.sh >> /tmp/cron-dbg.sync-mail.$(date -Id).log 2>&1";
      "0 * * * * andreh /home/andreh/dev/libre/dotfiles/scripts/cron/sync-mail.sh >> /tmp/cron-dbg.sync-mail.$(date -Id).log 2>&1";

    # Sync Nextcloud using nextcloudcmd every 15 minutes
    nextcloud =
    "*/15 * * * * andreh /home/andreh/dev/libre/dotfiles/scripts/cron/nextcloud.sh >> /tmp/cron-dbg.nextcloud.$(date -Id).log 2>&1";
      "*/15 * * * * andreh /home/andreh/dev/libre/dotfiles/scripts/cron/nextcloud.sh >> /tmp/cron-dbg.nextcloud.$(date -Id).log 2>&1";

    # Run ArchiveBox data once every day at 12h
    archivebox =
    "0 12 * * * andreh /home/andreh/dev/libre/dotfiles/scripts/cron/archive.sh >> /tmp/cron-dbg.archive.$(date -Id).log 2>&1";
      "0 12 * * * andreh /home/andreh/dev/libre/dotfiles/scripts/cron/archive.sh >> /tmp/cron-dbg.archive.$(date -Id).log 2>&1";

    # Borg backup once a month
    borg =
    "0 12 1 * * andreh /home/andreh/dev/libre/dotfiles/scripts/cron/backup.sh cron >> /tmp/cron-dbg.backup.$(date -Id).log 2>&1";
      "0 12 1 * * andreh /home/andreh/dev/libre/dotfiles/scripts/cron/backup.sh cron >> /tmp/cron-dbg.backup.$(date -Id).log 2>&1";
  };
}

M nixos/configuration.nix => nixos/configuration.nix +7 -7
@@ 2,8 2,8 @@

let
  pkgsUnstable = import (fetchTarball
  "https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz")
  { };
    "https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz")
    { };
  localConfiguration = pkgs.callPackage /etc/nixos/local-configuration.nix { };
in {
  imports = [ # Include the results of the hardware scan.


@@ 69,9 69,9 @@ in {
  environment.systemPackages = let
    timidityWithEvenMoreFormats = pkgs.timidity.overrideAttrs (oldAttrs: {
      configureFlags = oldAttrs.configureFlags
      ++ [ "--enable-audio=vorbis,flac" ];
        ++ [ "--enable-audio=vorbis,flac" ];
      buildInputs = oldAttrs.buildInputs
      ++ [ pkgs.libogg pkgs.libvorbis pkgs.flac ];
        ++ [ pkgs.libogg pkgs.libvorbis pkgs.flac ];
    });

    # See https://github.com/NixOS/nixpkgs/issues/53938#issuecomment-454158967


@@ 83,8 83,8 @@ in {
    # Should be removed during fresh OS installation:
    # https://github.com/NixOS/nix/issues/2497
    nixfmt = import
    (fetchTarball "https://github.com/serokell/nixfmt/archive/master.tar.gz")
    { };
      (fetchTarball "https://github.com/serokell/nixfmt/archive/master.tar.gz")
      { };

    # https://github.com/nixos/nixpkgs/blob/0d202221f98e500f1df79112dc464d013eefcdae/pkgs/development/web/nodejs/v10.nix#L4
  in with pkgs;


@@ 443,7 443,7 @@ in {
        description = "Build daemon for GNU Guix";
        serviceConfig = {
          ExecStart =
          "/var/guix/profiles/per-user/root/current-guix/bin/guix-daemon --build-users-group=guixbuild";
            "/var/guix/profiles/per-user/root/current-guix/bin/guix-daemon --build-users-group=guixbuild";
          Environment = "GUIX_LOCPATH=/root/.guix-profile/lib/locale";
          RemainAfterExit = "yes";
          StandardOutput = "syslog";

M nixos/hardware-configuration.nix => nixos/hardware-configuration.nix +2 -2
@@ 7,7 7,7 @@
  imports = [ <nixpkgs/nixos/modules/installer/scan/not-detected.nix> ];

  boot.initrd.availableKernelModules =
  [ "ehci_pci" "ahci" "usb_storage" "sd_mod" "sr_mod" ];
    [ "ehci_pci" "ahci" "usb_storage" "sd_mod" "sr_mod" ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];



@@ 22,7 22,7 @@
  };

  swapDevices =
  [{ device = "/dev/disk/by-uuid/c08158aa-677a-4984-83fe-c938edb7021e"; }];
    [{ device = "/dev/disk/by-uuid/c08158aa-677a-4984-83fe-c938edb7021e"; }];

  nix.maxJobs = lib.mkDefault 4;
  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";

M nixos/usurpador.nix => nixos/usurpador.nix +1 -2
@@ 9,6 9,5 @@ in {
  enableIPFS = false;
  allowUnfree = true; # Required for slack (unfree) derivation
  packages = with pkgs; [ sshuttle slack chromium ];
  cronJobs = [ common.cron.mail common.cron.nextcloud     common.cron.mail
 ];
  cronJobs = [ common.cron.mail common.cron.nextcloud common.cron.mail ];
}

M nixos/velhinho.nix => nixos/velhinho.nix +1 -5
@@ 9,9 9,5 @@ in {
  enableIPFS = false;
  allowUnfree = false;
  packages = with pkgs; [ transmission-gtk ];
  cronJobs = [
    common.cron.nextcloud
    common.cron.archivebox
    common.cron.borg
  ];
  cronJobs = [ common.cron.nextcloud common.cron.archivebox common.cron.borg ];
}

M utils.nix => utils.nix +70 -70
@@ 1,7 1,7 @@
{ pkgs, src, baseName }:
let
  nixfmt = import (builtins.fetchTarball
  "https://github.com/serokell/nixfmt/archive/master.tar.gz") { };
    "https://github.com/serokell/nixfmt/archive/master.tar.gz") { };
in rec {
  baseTask = pkgs.stdenv.mkDerivation {
    name = "${baseName}-task";


@@ 14,16 14,16 @@ in rec {
    '';
  };
  shellcheck = ignoredFindPattern:
  baseTask.overrideAttrs (baseAttrs: rec {
    name = "${baseAttrs.name}-shellcheck";
    buildInputs = baseAttrs.buildInputs ++ [ pkgs.shellcheck ];
    ignoredPattern =
    if ignoredFindPattern == null then "" else ignoredFindPattern;
    buildPhase = ''
      find . -type f \( -name '*.sh' -and -regextype egrep ! -regex '${ignoredPattern}' \) -print0 | xargs -0 shellcheck -x
      touch $out
    '';
  });
    baseTask.overrideAttrs (baseAttrs: rec {
      name = "${baseAttrs.name}-shellcheck";
      buildInputs = baseAttrs.buildInputs ++ [ pkgs.shellcheck ];
      ignoredPattern =
        if ignoredFindPattern == null then "" else ignoredFindPattern;
      buildPhase = ''
        find . -type f \( -name '*.sh' -and -regextype egrep ! -regex '${ignoredPattern}' \) -print0 | xargs -0 shellcheck -x
        touch $out
      '';
    });
  formatNix = baseTask.overrideAttrs (baseAttrs: {
    name = "${baseAttrs.name}-nixfmt";
    buildInputs = baseAttrs.buildInputs ++ [ nixfmt ];


@@ 42,68 42,68 @@ in rec {
    '';
  });
  fixme = ignoredFiles:
  baseTask.overrideAttrs (baseAttrs: rec {
    name = "${baseAttrs.name}-fixme";
    buildInputs = baseAttrs.buildInputs ++ [ pkgs.ag ];
    ignoredPattern = pkgs.lib.fold (a: b: " --ignore ${a} ${b}") ""
    (if ignoredFiles == null then [
      "utils.nix"
      "TODOs.org"
    ] else
      ignoredFiles);
    buildPhase = ''
      ag FIXME ${ignoredPattern} || {
        touch $out
        exit 0
      }
      echo "  Found dangling FIXME markers on the project."
      echo "  You should write them down properly on TODOs.org."
      exit 1
    '';
  });
    baseTask.overrideAttrs (baseAttrs: rec {
      name = "${baseAttrs.name}-fixme";
      buildInputs = baseAttrs.buildInputs ++ [ pkgs.ag ];
      ignoredPattern = pkgs.lib.fold (a: b: " --ignore ${a} ${b}") ""
        (if ignoredFiles == null then [
          "utils.nix"
          "TODOs.org"
        ] else
          ignoredFiles);
      buildPhase = ''
        ag FIXME ${ignoredPattern} || {
          touch $out
          exit 0
        }
        echo "  Found dangling FIXME markers on the project."
        echo "  You should write them down properly on TODOs.org."
        exit 1
      '';
    });
  readmeOrg = title:
  baseTask.overrideAttrs (baseAttrs: {
    name = "${baseAttrs.name}-readme-docs";
    buildInputs = [ pkgs.pandoc ];
    buildPhase = ''
      pandoc README.org -o $out --css docs/README.css --to=html5 --self-contained --metadata title="${title}"
    '';
  });
    baseTask.overrideAttrs (baseAttrs: {
      name = "${baseAttrs.name}-readme-docs";
      buildInputs = [ pkgs.pandoc ];
      buildPhase = ''
        pandoc README.org -o $out --css docs/README.css --to=html5 --self-contained --metadata title="${title}"
      '';
    });
  test = testDerivations:
  baseTask.overrideAttrs (baseAttrs: {
    name = "${baseAttrs.name}-test";
    buildPhase = ''
      echo "Ran tests for:"
      for d in ${builtins.toString testDerivations}; do
        echo "  $d"
      done
      echo "All tests passed!"
      touch $out
    '';
  });
    baseTask.overrideAttrs (baseAttrs: {
      name = "${baseAttrs.name}-test";
      buildPhase = ''
        echo "Ran tests for:"
        for d in ${builtins.toString testDerivations}; do
          echo "  $d"
        done
        echo "All tests passed!"
        touch $out
      '';
    });
  shellEnvironmentBuild = shellBuildInputs:
  baseTask.overrideAttrs (baseAttrs: {
    name = "${baseAttrs.name}-shell-build-inputs";
    buildPhase = ''
      echo "Can build shell environment for shellBuildInputs!"
      echo noop > $out
    '';
  });
    baseTask.overrideAttrs (baseAttrs: {
      name = "${baseAttrs.name}-shell-build-inputs";
      buildPhase = ''
        echo "Can build shell environment for shellBuildInputs!"
        echo noop > $out
      '';
    });
  shellEnvironment = shellBuildInputs:
  pkgs.mkShell {
    name = "${baseName}-shell";
    buildInputs = shellBuildInputs;
  };
    pkgs.mkShell {
      name = "${baseName}-shell";
      buildInputs = shellBuildInputs;
    };
  overwritingPublishScript = { docsDerivation, overwrite ? true }:
  pkgs.writeShellScriptBin "publish.sh" ''
    set -euo pipefail
    OUT_DOCS="${docsDerivation}"
    ${
      if overwrite then "" else "# "
    }${pkgs.openssh}/bin/ssh -o StrictHostKeyChecking=no "$SERVER_URL" rm -rf "$DOCS_SERVER_PATH/*"
    ${pkgs.rsync}/bin/rsync -avzP                                   \
                            --rsh="ssh -o StrictHostKeyChecking=no" \
                            "$OUT_DOCS/"                            \
                            "$SERVER_URL:$DOCS_SERVER_PATH"
  '';
    pkgs.writeShellScriptBin "publish.sh" ''
      set -euo pipefail
      OUT_DOCS="${docsDerivation}"
      ${
        if overwrite then "" else "# "
      }${pkgs.openssh}/bin/ssh -o StrictHostKeyChecking=no "$SERVER_URL" rm -rf "$DOCS_SERVER_PATH/*"
      ${pkgs.rsync}/bin/rsync -avzP                                   \
                              --rsh="ssh -o StrictHostKeyChecking=no" \
                              "$OUT_DOCS/"                            \
                              "$SERVER_URL:$DOCS_SERVER_PATH"
    '';
}