nixpkgs-fmt

This commit is contained in:
fleaz 2022-02-07 00:01:27 +01:00
parent 6a9a43478c
commit 04091588ee
10 changed files with 185 additions and 169 deletions

View file

@ -2,7 +2,8 @@
let let
home-manager = (import ../nix/sources.nix).home-manager; home-manager = (import ../nix/sources.nix).home-manager;
in { in
{
imports = [ imports = [
"${home-manager}/nixos" "${home-manager}/nixos"
]; ];
@ -10,8 +11,8 @@ in {
home-manager.users.fleaz = { pkgs, ... }: { home-manager.users.fleaz = { pkgs, ... }: {
imports = [ imports = [
modules/neovim.nix modules/neovim.nix
modules/vscode.nix modules/vscode.nix
]; ];
services.gnome-keyring.enable = true; services.gnome-keyring.enable = true;
@ -194,66 +195,68 @@ in {
bars = [{ command = "${pkgs.waybar}/bin/waybar"; }]; bars = [{ command = "${pkgs.waybar}/bin/waybar"; }];
keybindings = let mod = "Mod4"; keybindings =
in { let mod = "Mod4";
"${mod}+Return" = "exec foot"; in
"${mod}+p" = "exec ${pkgs.wofi}/bin/wofi --show drun"; {
"${mod}+Return" = "exec foot";
"${mod}+p" = "exec ${pkgs.wofi}/bin/wofi --show drun";
"${mod}+Shift+c" = "reload"; "${mod}+Shift+c" = "reload";
"${mod}+Shift+q" = "kill"; "${mod}+Shift+q" = "kill";
"${mod}+Shift+e" = "${mod}+Shift+e" =
"exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'"; "exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'";
"${mod}+x" = "move workspace to output right"; "${mod}+x" = "move workspace to output right";
"${mod}+h" = "focus left"; "${mod}+h" = "focus left";
"${mod}+j" = "focus down"; "${mod}+j" = "focus down";
"${mod}+k" = "focus up"; "${mod}+k" = "focus up";
"${mod}+l" = "focus right"; "${mod}+l" = "focus right";
"${mod}+Shift+h" = "move left"; "${mod}+Shift+h" = "move left";
"${mod}+Shift+j" = "move down"; "${mod}+Shift+j" = "move down";
"${mod}+Shift+k" = "move up"; "${mod}+Shift+k" = "move up";
"${mod}+Shift+l" = "move right"; "${mod}+Shift+l" = "move right";
"${mod}+s" = "split v"; "${mod}+s" = "split v";
"${mod}+w" = "split h"; "${mod}+w" = "split h";
"${mod}+t" = "layout tabbed"; "${mod}+t" = "layout tabbed";
"${mod}+r" = "mode resize"; "${mod}+r" = "mode resize";
"${mod}+f" = "fullscreen toggle"; "${mod}+f" = "fullscreen toggle";
"${mod}+Shift+space" = "floating toggle"; "${mod}+Shift+space" = "floating toggle";
"${mod}+1" = "workspace 1"; "${mod}+1" = "workspace 1";
"${mod}+2" = "workspace 2"; "${mod}+2" = "workspace 2";
"${mod}+3" = "workspace 3"; "${mod}+3" = "workspace 3";
"${mod}+4" = "workspace 4"; "${mod}+4" = "workspace 4";
"${mod}+5" = "workspace 5"; "${mod}+5" = "workspace 5";
"${mod}+6" = "workspace 6"; "${mod}+6" = "workspace 6";
"${mod}+7" = "workspace 7"; "${mod}+7" = "workspace 7";
"${mod}+8" = "workspace 8"; "${mod}+8" = "workspace 8";
"${mod}+9" = "workspace 9"; "${mod}+9" = "workspace 9";
"${mod}+0" = "workspace 10"; "${mod}+0" = "workspace 10";
"${mod}+Shift+1" = "move container to workspace 1"; "${mod}+Shift+1" = "move container to workspace 1";
"${mod}+Shift+2" = "move container to workspace 2"; "${mod}+Shift+2" = "move container to workspace 2";
"${mod}+Shift+3" = "move container to workspace 3"; "${mod}+Shift+3" = "move container to workspace 3";
"${mod}+Shift+4" = "move container to workspace 4"; "${mod}+Shift+4" = "move container to workspace 4";
"${mod}+Shift+5" = "move container to workspace 5"; "${mod}+Shift+5" = "move container to workspace 5";
"${mod}+Shift+6" = "move container to workspace 6"; "${mod}+Shift+6" = "move container to workspace 6";
"${mod}+Shift+7" = "move container to workspace 7"; "${mod}+Shift+7" = "move container to workspace 7";
"${mod}+Shift+8" = "move container to workspace 8"; "${mod}+Shift+8" = "move container to workspace 8";
"${mod}+Shift+9" = "move container to workspace 9"; "${mod}+Shift+9" = "move container to workspace 9";
"${mod}+Shift+0" = "move container to workspace 10"; "${mod}+Shift+0" = "move container to workspace 10";
# Multimedia Keys # Multimedia Keys
"XF86AudioMute" = "XF86AudioMute" =
"exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"; "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle";
"XF86AudioRaiseVolume" = "XF86AudioRaiseVolume" =
"exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%"; "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%";
"XF86AudioLowerVolume" = "XF86AudioLowerVolume" =
"exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%"; "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%";
}; };
}; };
}; };

View file

@ -1,10 +1,10 @@
{ pkgs, ... }: { { pkgs, ... }: {
programs.vim = { programs.vim = {
enable = true; enable = true;
plugins = with pkgs.vimPlugins; [ vim-airline neoformat vim-monokai ]; plugins = with pkgs.vimPlugins; [ vim-airline neoformat vim-monokai ];
settings = { ignorecase = true; }; settings = { ignorecase = true; };
extraConfig = '' extraConfig = ''
set mouse=a set mouse=a
''; '';
}; };
} }

View file

@ -1,13 +1,13 @@
{ pkgs, ... }: { { pkgs, ... }: {
programs.vscode = { programs.vscode = {
enable = true; enable = true;
package = pkgs.vscodium; # You can skip this if you want to use the unfree version package = pkgs.vscodium; # You can skip this if you want to use the unfree version
extensions = with pkgs.vscode-extensions; [ extensions = with pkgs.vscode-extensions; [
dracula-theme.theme-dracula dracula-theme.theme-dracula
vscodevim.vim vscodevim.vim
yzhang.markdown-all-in-one yzhang.markdown-all-in-one
ms-python.python ms-python.python
]; ];
}; };
} }

View file

@ -3,8 +3,9 @@
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ sources ? import ../../nix { sources ? import ../../nix
, pkgs ? sources.pkgs {} , pkgs ? sources.pkgs { }
, ... } : , ...
}:
{ {
imports = [ imports = [
@ -42,32 +43,32 @@
dockerCompat = true; dockerCompat = true;
}; };
# output = { # output = {
# "*".bg = "/home/fleaz/Downloads/spongebob.jpg fill"; # "*".bg = "/home/fleaz/Downloads/spongebob.jpg fill";
# "DVI-D-1" = { # "DVI-D-1" = {
# mode = "1920x1200"; # mode = "1920x1200";
# transform = "270"; # transform = "270";
# position = "0,0"; # position = "0,0";
# }; # };
# "HDMI-A-1" = { # "HDMI-A-1" = {
# mode = "3840x2160"; # mode = "3840x2160";
# scale = "1.2"; # scale = "1.2";
# position = "1200,0"; # position = "1200,0";
# }; # };
# "DP-1" = { # "DP-1" = {
# mode = "3840x2160"; # mode = "3840x2160";
# scale = "1.2"; # scale = "1.2";
# position = "4400,0"; # position = "4400,0";
# }; # };
# Multimedia Keys # Multimedia Keys
# "XF86AudioMute" = # "XF86AudioMute" =
# "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"; # "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle";
# "XF86AudioRaiseVolume" = # "XF86AudioRaiseVolume" =
# "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%"; # "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%";
# "XF86AudioLowerVolume" = # "XF86AudioLowerVolume" =
# "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%"; # "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%";
# List packages installed in system profile. To search, run: # List packages installed in system profile. To search, run:
# $ nix search wget # $ nix search wget

View file

@ -23,13 +23,15 @@
}; };
fileSystems."/mnt/pool" = { fileSystems."/mnt/pool" = {
device = "//BART/Pool/"; device = "//BART/Pool/";
fsType = "cifs"; fsType = "cifs";
options = let options =
let
# this line prevents hanging on network split # this line prevents hanging on network split
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s"; automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
in ["${automount_opts},credentials=/etc/nixos/smb-secrets"]; in
[ "${automount_opts},credentials=/etc/nixos/smb-secrets" ];
}; };
swapDevices = swapDevices =

View file

@ -7,7 +7,8 @@
let let
home-manager = (import ./nix/sources.nix).home-manager; home-manager = (import ./nix/sources.nix).home-manager;
secretsFile = "/root.key"; secretsFile = "/root.key";
in { in
{
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
@ -40,13 +41,13 @@ in {
networking.hostName = "jimbo"; # Define your hostname. networking.hostName = "jimbo"; # Define your hostname.
networking.extraHosts = networking.extraHosts =
'' ''
10.32.4.64 cyberark.charite.de 10.32.4.64 cyberark.charite.de
10.32.4.64 cya-pvwa.charite.de 10.32.4.64 cya-pvwa.charite.de
141.42.207.84 s-charitedigital.charite.de 141.42.207.84 s-charitedigital.charite.de
10.32.4.65 cya-psmp.charite.de 10.32.4.65 cya-psmp.charite.de
''; '';
# Set your time zone. # Set your time zone.
time.timeZone = "Europe/Berlin"; time.timeZone = "Europe/Berlin";
@ -56,12 +57,12 @@ in {
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
programs.nm-applet.enable = true; programs.nm-applet.enable = true;
services.avahi = { services.avahi = {
nssmdns = true; nssmdns = true;
enable = true; enable = true;
ipv4 = true; ipv4 = true;
ipv6 = true; ipv6 = true;
}; };
hardware.opengl = { hardware.opengl = {
enable = true; enable = true;
@ -98,8 +99,11 @@ in {
# List packages installed in system profile. To search, run: # List packages installed in system profile. To search, run:
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
vim wget curl git vim
]; wget
curl
git
];
services.openssh.enable = true; services.openssh.enable = true;
programs.ssh.startAgent = true; programs.ssh.startAgent = true;

View file

@ -5,7 +5,8 @@
{ {
imports = imports =
[ (modulesPath + "/installer/scan/not-detected.nix") [
(modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
@ -14,14 +15,16 @@
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" =
{ device = "/dev/disk/by-uuid/b9edb32f-fb40-4d59-8abe-b187c88667d6"; {
device = "/dev/disk/by-uuid/b9edb32f-fb40-4d59-8abe-b187c88667d6";
fsType = "ext4"; fsType = "ext4";
}; };
boot.initrd.luks.devices."cryptroot".device = "/dev/disk/by-uuid/e2d53876-3fdc-486a-a354-ec834b256e43"; boot.initrd.luks.devices."cryptroot".device = "/dev/disk/by-uuid/e2d53876-3fdc-486a-a354-ec834b256e43";
fileSystems."/boot/efi" = fileSystems."/boot/efi" =
{ device = "/dev/disk/by-uuid/502E-A0DC"; {
device = "/dev/disk/by-uuid/502E-A0DC";
fsType = "vfat"; fsType = "vfat";
}; };

View file

@ -1,4 +1,4 @@
{ ... }:{ { ... }: {
services.openssh.enable = true; services.openssh.enable = true;
programs.ssh.startAgent = true; programs.ssh.startAgent = true;
} }

View file

@ -10,29 +10,29 @@ let
let let
name' = sanitizeName name + "-src"; name' = sanitizeName name + "-src";
in in
if spec.builtin or true then if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; name = name'; } builtins_fetchurl { inherit (spec) url sha256; name = name'; }
else else
pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
fetch_tarball = pkgs: name: spec: fetch_tarball = pkgs: name: spec:
let let
name' = sanitizeName name + "-src"; name' = sanitizeName name + "-src";
in in
if spec.builtin or true then if spec.builtin or true then
builtins_fetchTarball { name = name'; inherit (spec) url sha256; } builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
else else
pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
fetch_git = name: spec: fetch_git = name: spec:
let let
ref = ref =
if spec ? ref then spec.ref else if spec ? ref then spec.ref else
if spec ? branch then "refs/heads/${spec.branch}" else if spec ? branch then "refs/heads/${spec.branch}" else
if spec ? tag then "refs/tags/${spec.tag}" else if spec ? tag then "refs/tags/${spec.tag}" else
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
in in
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
fetch_local = spec: spec.path; fetch_local = spec: spec.path;
@ -66,16 +66,16 @@ let
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.; hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in in
if builtins.hasAttr "nixpkgs" sources if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> {} import <nixpkgs> { }
else else
abort abort
'' ''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json. add a package called "nixpkgs" to your sources.json.
''; '';
# The actual fetching function. # The actual fetching function.
fetch = pkgs: name: spec: fetch = pkgs: name: spec:
@ -98,10 +98,10 @@ let
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
in in
if ersatz == "" then drv else if ersatz == "" then drv else
# this turns the string into an actual Nix path (for both absolute and # this turns the string into an actual Nix path (for both absolute and
# relative paths) # relative paths)
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
# Ports of functions for older nix versions # Ports of functions for older nix versions
@ -112,7 +112,7 @@ let
); );
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); range = first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
@ -123,43 +123,46 @@ let
concatStrings = builtins.concatStringsSep ""; concatStrings = builtins.concatStringsSep "";
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
optionalAttrs = cond: as: if cond then as else {}; optionalAttrs = cond: as: if cond then as else { };
# fetchTarball version that is compatible between all the versions of Nix # fetchTarball version that is compatible between all the versions of Nix
builtins_fetchTarball = { url, name ? null, sha256 }@attrs: builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
let let
inherit (builtins) lessThan nixVersion fetchTarball; inherit (builtins) lessThan nixVersion fetchTarball;
in in
if lessThan nixVersion "1.12" then if lessThan nixVersion "1.12" then
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else else
fetchTarball attrs; fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix # fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, name ? null, sha256 }@attrs: builtins_fetchurl = { url, name ? null, sha256 }@attrs:
let let
inherit (builtins) lessThan nixVersion fetchurl; inherit (builtins) lessThan nixVersion fetchurl;
in in
if lessThan nixVersion "1.12" then if lessThan nixVersion "1.12" then
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else else
fetchurl attrs; fetchurl attrs;
# Create the final "sources" from the config # Create the final "sources" from the config
mkSources = config: mkSources = config:
mapAttrs ( mapAttrs
name: spec: (
if builtins.hasAttr "outPath" spec name: spec:
then abort if builtins.hasAttr "outPath" spec
"The values in sources.json should not have an 'outPath' attribute" then
else abort
spec // { outPath = replace name (fetch config.pkgs name spec); } "The values in sources.json should not have an 'outPath' attribute"
) config.sources; else
spec // { outPath = replace name (fetch config.pkgs name spec); }
)
config.sources;
# The "config" used by the fetchers # The "config" used by the fetchers
mkConfig = mkConfig =
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) , sources ? if isNull sourcesFile then { } else builtins.fromJSON (builtins.readFile sourcesFile)
, system ? builtins.currentSystem , system ? builtins.currentSystem
, pkgs ? mkPkgs sources system , pkgs ? mkPkgs sources system
}: rec { }: rec {
@ -171,4 +174,4 @@ let
}; };
in in
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); }

View file

@ -1,4 +1,4 @@
{ {
imports = [ imports = [
../home-manager/default.nix ../home-manager/default.nix
../modules/earlyoom.nix ../modules/earlyoom.nix
@ -9,5 +9,5 @@
../modules/ssh.nix ../modules/ssh.nix
../users/fleaz.nix ../users/fleaz.nix
]; ];
} }