Compare commits

..

No commits in common. "6352f821c371f16a9f1bacc48af186d2d9b8b697" and "1537fea0bd3da339dfb41415dc7e8bb4e0b7ec55" have entirely different histories.

102 changed files with 2369 additions and 2910 deletions

View File

@ -1,13 +1,11 @@
# We use top-level nix-flake, so default.nix is basically just a wrapper around ./flake.nix # We use top-level nix-flake, so default.nix is basically just a wrapper around ./flake.nix
( (import
import
( (
let let
lock = builtins.fromJSON (builtins.readFile ./flake.lock); lock = builtins.fromJSON (builtins.readFile ./flake.lock);
c_ = import ./c_.nix; c_ = import ./c_.nix;
in in
c_.fetchTree lock.nodes.flake-compat.locked c_.fetchTree lock.nodes.flake-compat.locked
) )
{src = ./.;} { src = ./.; }
) ).defaultNix
.defaultNix

View File

@ -1,15 +1,13 @@
# Ideally, this should contain the barebone necessary for building/interacting # Ideally, this should contain the barebone necessary for building/interacting
# with tech used in this project # with tech used in this project
# #
# Should also incorporate shortcuts like scripts/{hm-switch,conf-sysnix}.sh in here instead # Should also incorporate shortcuts like scripts/{hm-switch,conf-sysnix}.sh in here instead
# #
# It should not contain PDE # It should not contain PDE
{ { pkgs ? import <nixpkgs> { }
pkgs ? import <nixpkgs> {}, , lib
lib, , ...
... }: pkgs.mkShell {
}:
pkgs.mkShell {
# mkShell doesn't care about the differences across nativeBuildInputs, # mkShell doesn't care about the differences across nativeBuildInputs,
# buildInputs, or packages # buildInputs, or packages
buildInputs = [ buildInputs = [
@ -22,9 +20,10 @@ pkgs.mkShell {
]; ];
shellHook = '' shellHook = ''
# Since we need late dispatch of ~, we have to put this in shellHook. # Since we need late dispatch of ~, we have to put this in shellHook.
export SOPS_AGE_KEY_FILE=~/.config/sops/age/keys.txt export SOPS_AGE_KEY_FILE=~/.config/sops/age/keys.txt
''; '';
# env vars # env vars
lol = "hello world"; lol = "hello world";
} }

View File

@ -1,12 +0,0 @@
# Neovim: Testing cmp for color with Tailwind
- [ ] It should detect a project uses tailwind, maybe via some kind of config file
(`tailwind.config.{cjs,mjs,js,ts,json,tsx,toml,yaml}`), or just based on the
string content or via tree-stiter. Check this by `:LspInfo` and `tailwindcss-lsp`
should attach to the current buffer that has tailwind-css string
- [ ] Type in a classname `text-red-500`, just stop at somewhere and start
browsing the cmp-lsp window. It should show a color in place of `lspkind`.
This validates `tailwindcss-colorizer-cmp.nvim` is good
- [ ] Hit that autocomplete, the string should show the color red. This validates
`nvim-colorizer.lua` is properly setup.

View File

@ -429,11 +429,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1686960236, "lastModified": 1686869522,
"narHash": "sha256-AYCC9rXNLpUWzD9hm+askOfpliLEC9kwAo7ITJc4HIw=", "narHash": "sha256-tbJ9B8WLCTnVP/LwESRlg0dII6Zyg2LmUU/mB9Lu98E=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "04af42f3b31dba0ef742d254456dc4c14eedac86", "rev": "7c67f006ea0e7d0265f16d7df07cc076fdffd91f",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -9,11 +9,10 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
deploy-rs.url = "github:serokell/deploy-rs"; deploy-rs.url = "github:serokell/deploy-rs";
std.url = "github:divnix/std"; std.url = "github:divnix/std";
rust-overlay = "github:oxalica/rust-overlay.git"; hive.url = "github:divnix/hive";
}; };
outputs = {std, ...} @ inputs: outputs = { std, hive, ... }@inputs: std.growOn
std.growOn
{ {
# boilerplate # boilerplate
inherit inputs; inherit inputs;
@ -22,23 +21,22 @@
cellsFrom = ./nix/cells; cellsFrom = ./nix/cells;
# modules = ./nix/modules; # modules = ./nix/modules;
cellBlocks = let cellBlocks =
inherit (std.blockTypes) devshells functions; let
in [ inherit (std.blockTypes) devshells functions;
(devshells "devshells") in
(devshells "userShells") [
(functions "home-profiles") (devshells "devshells")
(functions "home-modules") (devshells "userShells")
]; # (functions "host_profile")
# (functions "home_profile")
];
} }
{ {
devShells = std.harvest [["dotfiles" "devshells"]]; devShells = std.harvest [ [ "dotfiles" "devshells" ] ];
# nixosConfigurations = std.pick [ [ "dotfiles" "nixos" ] ]; # nixosConfigurations = std.pick [ [ "dotfiles" "nixos" ] ];
# homeConfigurations = std.pick [ [ "dotfiles" "home" ] ]; # homeConfigurations = std.pick [ [ "dotfiles" "home" ] ];
homeModules = std.pick [["repo" "home-modules"]]; homeModules = std.pick [["repo" "home-modules"]];
# TODO: Debug only
homeProfiles = std.pick [["repo" "home-profiles"]];
packages = std.harvest [["repo" "home-configs"]];
}; };
} }

View File

@ -1,19 +1,15 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ { config, lib, pkgs, modulesPath, ... }:
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [];
boot.initrd.availableKernelModules = []; {
boot.initrd.kernelModules = []; imports = [ ];
boot.kernelModules = [];
boot.extraModulePackages = []; boot.initrd.availableKernelModules = [ ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
## NOTE: These filesystems are mounted by a wrapper script from nix-wsl ## NOTE: These filesystems are mounted by a wrapper script from nix-wsl
@ -47,22 +43,25 @@
# fsType = "drvfs"; # fsType = "drvfs";
# }; # };
fileSystems."/mnt/c" = { fileSystems."/mnt/c" =
device = "C:"; {
fsType = "drvfs"; device = "C:";
}; fsType = "drvfs";
};
fileSystems."/mnt/d" = { fileSystems."/mnt/d" =
device = "D:"; {
fsType = "drvfs"; device = "D:";
}; fsType = "drvfs";
};
fileSystems."/mnt/f" = { fileSystems."/mnt/f" =
device = "F:"; {
fsType = "drvfs"; device = "F:";
}; fsType = "drvfs";
};
swapDevices = []; swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,12 +1,12 @@
{ { nixpkgs
nixpkgs, , agenix
agenix, , home-manager
home-manager, , flake-utils
flake-utils, , nixgl
nixgl, , rust-overlay
rust-overlay, , flake-compat
flake-compat, , pkgs
pkgs, , lib
lib, , proj_root
proj_root, }: { }
}: {}

View File

@ -1,23 +1,20 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
config, imports =
lib, [
pkgs, (modulesPath + "/installer/scan/not-detected.nix")
modulesPath, ];
...
}: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod"]; boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
# boot.initrd.kernelModules = [ "amdgpu" ]; # boot.initrd.kernelModules = [ "amdgpu" ];
boot.initrd.kernelModules = []; boot.initrd.kernelModules = [ ];
boot.kernelModules = ["kvm-amd" "coretemp"]; boot.kernelModules = [ "kvm-amd" "coretemp" ];
boot.extraModulePackages = []; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" =
# Might be wise to use /dev/nvme0p1 instead # Might be wise to use /dev/nvme0p1 instead
@ -33,7 +30,7 @@
fsType = "vfat"; fsType = "vfat";
}; };
swapDevices = []; swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,18 +1,18 @@
{ { nixpkgs
nixpkgs, , agenix
agenix, , home-manager
home-manager, , flake-utils
flake-utils, , nixgl
nixgl, , rust-overlay
rust-overlay, , flake-compat
flake-compat, , pkgs
pkgs, , lib
lib, , proj_root
proj_root, , nixosDefaultVersion ? "22.05"
nixosDefaultVersion ? "22.05", , defaultSystem ? "x86_64-linux"
defaultSystem ? "x86_64-linux", , ...
... }@finalInputs:
} @ finalInputs: let let
config = { config = {
bao.metadata = { bao.metadata = {
# req # req
@ -33,58 +33,54 @@
]; ];
}; };
}; };
propagate = hostConfig @ { propagate = hostConfig@{ metadata, nixosConfig }:
metadata, let
nixosConfig, # req
}: let inherit (metadata) hostName;
# req # opts
inherit (metadata) hostName; ssh_pubkey = lib.attrByPath [ "ssh_pubkey" ] null metadata; # metadata.ssh_pubkey??undefined
# opts users = lib.attrByPath [ "users" ] { } metadata;
ssh_pubkey = lib.attrByPath ["ssh_pubkey"] null metadata; # metadata.ssh_pubkey??undefined nixosVersion = lib.attrByPath [ "nixosVersion" ] nixosDefaultVersion metadata;
users = lib.attrByPath ["users"] {} metadata; system = lib.attrByPath [ "system" ] defaultSystem metadata;
nixosVersion = lib.attrByPath ["nixosVersion"] nixosDefaultVersion metadata; preset = lib.attrByPath [ "preset" ] "base" metadata;
system = lib.attrByPath ["system"] defaultSystem metadata; # infer
preset = lib.attrByPath ["preset"] "base" metadata; hardwareConfig = import "${proj_root.hosts.path}/${hostName}/hardware-configuration.nix";
# infer # alias to prevent infinite recursion
hardwareConfig = import "${proj_root.hosts.path}/${hostName}/hardware-configuration.nix"; _nixosConfig = nixosConfig;
# alias to prevent infinite recursion in
_nixosConfig = nixosConfig; {
in { inherit hostName ssh_pubkey users nixosVersion system preset hardwareConfig;
inherit hostName ssh_pubkey users nixosVersion system preset hardwareConfig; nixosConfig = _nixosConfig // {
nixosConfig =
_nixosConfig
// {
inherit system; inherit system;
modules = modules = [
[ {
{ config._module.args = {
config._module.args = { inherit proj_root;
inherit proj_root; my-lib = finalInputs.lib;
my-lib = finalInputs.lib; };
}; }
} hardwareConfig
hardwareConfig {
{ system.stateVersion = nixosVersion;
system.stateVersion = nixosVersion; networking.hostName = hostName;
networking.hostName = hostName; users.users = users;
users.users = users; }
} {
{ imports = [ agenix.nixosModule ];
imports = [agenix.nixosModule]; environment.systemPackages = [ agenix.defaultPackage.x86_64-linux ];
environment.systemPackages = [agenix.defaultPackage.x86_64-linux]; }
} (import "${proj_root.modules.path}/secrets.nix")
(import "${proj_root.modules.path}/secrets.nix") (import "${proj_root.modules.path}/${preset}.sys.nix")
(import "${proj_root.modules.path}/${preset}.sys.nix") ] ++ _nixosConfig.modules;
]
++ _nixosConfig.modules;
}; };
}; };
# we are blessed by the fact that we engulfed nixpkgs.lib.* at top level # we are blessed by the fact that we engulfed nixpkgs.lib.* at top level
mkHostFromPropagated = propagatedHostConfig @ {nixosConfig, ...}: nixpkgs.lib.nixosSystem nixosConfig; mkHostFromPropagated = propagatedHostConfig@{ nixosConfig, ... }: nixpkgs.lib.nixosSystem nixosConfig;
mkHost = hostConfig: (lib.pipe [propagate mkHostFromPropagated] hostConfig); mkHost = hostConfig: (lib.pipe [ propagate mkHostFromPropagated ] hostConfig);
trimNull = lib.filterAttrsRecursive (name: value: value != null); trimNull = lib.filterAttrsRecursive (name: value: value != null);
flattenPubkey = lib.mapAttrs (hostName: meta_config: meta_config.metadata.ssh_pubkey); flattenPubkey = lib.mapAttrs (hostName: meta_config: meta_config.metadata.ssh_pubkey);
in { in
{
nixosConfigurations = lib.mapAttrs (name: hostConfig: mkHost hostConfig) config; nixosConfigurations = lib.mapAttrs (name: hostConfig: mkHost hostConfig) config;
# {bao = "ssh-ed25519 ..."; another_host = "ssh-rsa ...";} # {bao = "ssh-ed25519 ..."; another_host = "ssh-rsa ...";}
pubKeys = lib.getPubkey config; pubKeys = lib.getPubkey config;

View File

@ -1,20 +1,17 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ { config, lib, pkgs, modulesPath, ... }:
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; {
boot.initrd.kernelModules = []; imports =
boot.kernelParams = ["console=ttyS0,19200n8"]; [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -23,15 +20,17 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
boot.kernelModules = []; boot.kernelModules = [ ];
boot.extraModulePackages = []; boot.extraModulePackages = [ ];
fileSystems."/" = { fileSystems."/" =
device = "/dev/sda"; {
fsType = "ext4"; device = "/dev/sda";
}; fsType = "ext4";
};
swapDevices = [{device = "/dev/sdb";}]; swapDevices =
[{ device = "/dev/sdb"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,20 +1,17 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ { config, lib, pkgs, modulesPath, ... }:
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; {
boot.initrd.kernelModules = []; imports =
boot.kernelParams = ["console=ttyS0,19200n8"]; [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -23,15 +20,17 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
boot.kernelModules = []; boot.kernelModules = [ ];
boot.extraModulePackages = []; boot.extraModulePackages = [ ];
fileSystems."/" = { fileSystems."/" =
device = "/dev/sda"; {
fsType = "ext4"; device = "/dev/sda";
}; fsType = "ext4";
};
swapDevices = [{device = "/dev/sdb";}]; swapDevices =
[{ device = "/dev/sdb"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,12 +1,11 @@
{ { nixpkgs
nixpkgs, , agenix
agenix, , home-manager
home-manager, , flake-utils
flake-utils, , nixgl
nixgl, , rust-overlay
rust-overlay, , flake-compat
flake-compat, , pkgs
pkgs, , lib
lib, , proj_root
proj_root, }: { }
}: {}

View File

@ -1,20 +1,17 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ { config, lib, pkgs, modulesPath, ... }:
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; {
boot.initrd.kernelModules = []; imports =
boot.kernelParams = ["console=ttyS0,19200n8"]; [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -23,8 +20,8 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
boot.kernelModules = []; boot.kernelModules = [ ];
boot.extraModulePackages = []; boot.extraModulePackages = [ ];
fileSystems = { fileSystems = {
"/" = { "/" = {
@ -38,7 +35,8 @@
}; };
}; };
swapDevices = [{device = "/dev/sdb";}]; swapDevices =
[{ device = "/dev/sdb"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,23 +1,20 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
config, imports =
lib, [
pkgs, (modulesPath + "/profiles/qemu-guest.nix")
modulesPath, ];
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
boot.initrd.kernelModules = []; boot.initrd.kernelModules = [ ];
boot.kernelModules = []; boot.kernelModules = [ ];
boot.extraModulePackages = []; boot.extraModulePackages = [ ];
boot.kernelParams = ["console=ttyS0,19200n8"]; boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -26,12 +23,14 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
fileSystems."/" = { fileSystems."/" =
device = "/dev/sda"; {
fsType = "ext4"; device = "/dev/sda";
}; fsType = "ext4";
};
swapDevices = [{device = "/dev/sdb";}]; swapDevices =
[{ device = "/dev/sdb"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,6 +1,6 @@
{ {
imports = [./gpu.sys.nix]; imports = [ ./gpu.sys.nix ];
boot.initrd.kernelModules = ["amdgpu"]; boot.initrd.kernelModules = [ "amdgpu" ];
services.xserver.enable = true; services.xserver.enable = true;
services.xserver.videoDrivers = ["amdgpu"]; services.xserver.videoDrivers = [ "amdgpu" ];
} }

View File

@ -1,8 +1,7 @@
{ { pkgs
pkgs, , lib
lib, , proj_root
proj_root, , ...
...
}: { }: {
imports = [ imports = [
./minimal.sys.nix ./minimal.sys.nix
@ -10,6 +9,7 @@
./tailscale.sys.nix ./tailscale.sys.nix
./ssh.sys.nix ./ssh.sys.nix
]; ];
environment.systemPackages = [pkgs.lm_sensors]; environment.systemPackages = [ pkgs.lm_sensors ];
time.timeZone = "America/Phoenix"; time.timeZone = "America/Phoenix";
} }

View File

@ -1 +1 @@
inputs: {} inputs: { }

View File

@ -1,8 +1,8 @@
{pkgs, ...}: { { pkgs, ... }: {
environment.systemPackages = [pkgs.clinfo pkgs.lshw pkgs.glxinfo pkgs.pciutils pkgs.vulkan-tools]; environment.systemPackages = [ pkgs.clinfo pkgs.lshw pkgs.glxinfo pkgs.pciutils pkgs.vulkan-tools ];
hardware.opengl = { hardware.opengl = {
enable = true; enable = true;
extraPackages = [pkgs.rocm-opencl-icd pkgs.rocm-opencl-runtime]; extraPackages = [ pkgs.rocm-opencl-icd pkgs.rocm-opencl-runtime ];
# Vulkan # Vulkan
driSupport = true; driSupport = true;
driSupport32Bit = true; driSupport32Bit = true;

View File

@ -1,7 +1,6 @@
{ { pkgs
pkgs, , my-lib
my-lib, , ...
...
}: { }: {
environment.noXlibs = my-lib.mkForce false; environment.noXlibs = my-lib.mkForce false;
# TODO: wireless networking # TODO: wireless networking
@ -12,16 +11,15 @@
services.xserver.displayManager.sddm.enable = true; services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5 = { services.xserver.desktopManager.plasma5 = {
enable = true; enable = true;
excludePackages = let excludePackages = let plasma5 = pkgs.libsForQt5; in
plasma5 = pkgs.libsForQt5; [
in [ plasma5.elisa # audio viewer
plasma5.elisa # audio viewer plasma5.konsole # I use alacritty instaed
plasma5.konsole # I use alacritty instaed plasma5.plasma-browser-integration
plasma5.plasma-browser-integration plasma5.print-manager # will enable if I need
plasma5.print-manager # will enable if I need plasma5.khelpcenter # why not just write manpages instead :(
plasma5.khelpcenter # why not just write manpages instead :( # plasma5.ksshaskpass # pls just put prompts on my dear terminal
# plasma5.ksshaskpass # pls just put prompts on my dear terminal ];
];
}; };
# disables KDE's setting of askpassword # disables KDE's setting of askpassword

View File

@ -1,11 +1,10 @@
{ { pkgs
pkgs, , lib
lib, , proj_root
proj_root, , modulesPath
modulesPath, , ...
...
}: { }: {
imports = ["${modulesPath}/profiles/minimal.nix"]; imports = [ "${modulesPath}/profiles/minimal.nix" ];
# prune old builds after a while # prune old builds after a while
nix.settings.auto-optimise-store = true; nix.settings.auto-optimise-store = true;
nix.package = pkgs.nixFlakes; # nix flakes nix.package = pkgs.nixFlakes; # nix flakes

View File

@ -1,11 +1,10 @@
{ pkgs
, lib
, config
, ...
}:
let cfg = config.mod.mosh; in
{ {
pkgs,
lib,
config,
...
}: let
cfg = config.mod.mosh;
in {
options.mod.mosh = { options.mod.mosh = {
enable = lib.mkOption { enable = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
@ -15,14 +14,12 @@ in {
}; };
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [pkgs.mosh]; environment.systemPackages = [ pkgs.mosh ];
networking.firewall = lib.mkIf config.networking.firewall.enable { networking.firewall = lib.mkIf config.networking.firewall.enable {
allowedUDPPortRanges = [ allowedUDPPortRanges = [
{ { from = 60000; to = 61000; } # mosh
from = 60000;
to = 61000;
} # mosh
]; ];
}; };
}; };
} }

View File

@ -1,7 +1,7 @@
{config, ...}: { { config, ... }: {
imports = [./gpu.sys.nix]; imports = [ ./gpu.sys.nix ];
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
services.xserver.enable = true; services.xserver.enable = true;
services.xserver.videoDrivers = ["nvidia"]; services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable; hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
} }

View File

@ -1,16 +1,15 @@
{ { config, pkgs, lib }:
config, let
pkgs, gpu_pkgs = [ pkgs.clinfo pkgs.lshw pkgs.glxinfo pkgs.pciutils pkgs.vulkan-tools ];
lib,
}: let
gpu_pkgs = [pkgs.clinfo pkgs.lshw pkgs.glxinfo pkgs.pciutils pkgs.vulkan-tools];
gpu_conf = { gpu_conf = {
# openCL # openCL
hardware.opengl = { hardware.opengl = {
enable = true; enable = true;
extraPackages = let extraPackages =
inherit (pkgs) rocm-opencl-icd rocm-opencl-runtime; let
in [rocm-opencl-icd rocm-opencl-runtime]; inherit (pkgs) rocm-opencl-icd rocm-opencl-runtime;
in
[ rocm-opencl-icd rocm-opencl-runtime ];
# Vulkan # Vulkan
driSupport = true; driSupport = true;
driSupport32Bit = true; driSupport32Bit = true;
@ -19,5 +18,4 @@
}; };
environment.systemPackages = gpu_pkgs; environment.systemPackages = gpu_pkgs;
}; };
in in gpu_conf
gpu_conf

View File

@ -1,4 +1,6 @@
{proj_root, ...}: { { proj_root
, ...
}: {
age.secrets.s3fs = { age.secrets.s3fs = {
file = "${proj_root.secrets.path}/s3fs.age"; file = "${proj_root.secrets.path}/s3fs.age";
# mode = "600"; # owner + group only # mode = "600"; # owner + group only

View File

@ -1,10 +1,5 @@
# Personal configuration on storage solution # Personal configuration on storage solution
{ { pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}: {
environment.systemPackages = [ environment.systemPackages = [
pkgs.s3fs pkgs.s3fs
pkgs.cifs-utils pkgs.cifs-utils
@ -14,81 +9,87 @@
# HACK: need to store secret somewhere so that root can access this # HACK: need to store secret somewhere so that root can access this
# because autofs may run as root for now, we enforce putting the secret in this monorepo # because autofs may run as root for now, we enforce putting the secret in this monorepo
# TODO: make this configuration nix-less to show that it's 100% data # TODO: make this configuration nix-less to show that it's 100% data
services.autofs = let services.autofs =
# confToBackendArg {lol="what"; empty=""; name_only=null;} -> "lol=what,empty=,name_only" let
# TODO: change null -> true/false. This allows overriding & better self-documentation # confToBackendArg {lol="what"; empty=""; name_only=null;} -> "lol=what,empty=,name_only"
confToBackendArg = conf: (lib.concatStringsSep "," # TODO: change null -> true/false. This allows overriding & better self-documentation
(lib.mapAttrsToList (name: value: "${name}${lib.optionalString (value != null) "=${value}"}") conf)); confToBackendArg = conf: (lib.concatStringsSep ","
(lib.mapAttrsToList (name: value: "${name}${lib.optionalString (value != null) "=${value}"}") conf));
# mount_dest: path ("wow") # mount_dest: path ("wow")
# backend_args: nix attrs representing the arguments to be passed to s3fs # backend_args: nix attrs representing the arguments to be passed to s3fs
# ({"-fstype" = "fuse"; "use_cache" = "/tmp";}) # ({"-fstype" = "fuse"; "use_cache" = "/tmp";})
# bucket: bucket name (hungtr-hot) # bucket: bucket name (hungtr-hot)
# NOTE: s3 custom provider will be provided inside # NOTE: s3 custom provider will be provided inside
# backend_args, so just put the bucket name here # backend_args, so just put the bucket name here
# #
#-> "${mount_dest} ${formatted_args} ${s3fs-bin}#${bucket}" #-> "${mount_dest} ${formatted_args} ${s3fs-bin}#${bucket}"
autofs-s3fs_entry = { autofs-s3fs_entry =
mount_dest, { mount_dest
backend_args ? {"-fstype" = "fuse";}, , backend_args ? { "-fstype" = "fuse"; }
bucket, , bucket
} @ inputs: let }@inputs:
s3fs-exec = "${pkgs.s3fs}/bin/s3fs";
in "${mount_dest} ${confToBackendArg backend_args} :${s3fs-exec}\#${bucket}";
personalStorage = [
(autofs-s3fs_entry {
mount_dest = "garden";
backend_args = {
"-fstype" = "fuse";
use_cache = "/tmp";
del_cache = null;
allow_other = null;
url = "https://v5h5.la11.idrivee2-14.com";
passwd_file = config.age.secrets."s3fs.digital-garden".path;
dbglevel = "debug"; # enable this for better debugging info in journalctl
uid = "1000"; # default user
gid = "100"; # users
umask = "003"; # others read only, fully shared for users group
};
bucket = "digital-garden";
})
(
let let
args = { s3fs-exec = "${pkgs.s3fs}/bin/s3fs";
"-fstype" = "cifs"; in
credentials = config.age.secrets._nhitrl_cred.path; "${mount_dest} ${confToBackendArg backend_args} :${s3fs-exec}\#${bucket}";
user = null; personalStorage = [
uid = "1001"; (autofs-s3fs_entry {
gid = "100"; mount_dest = "garden";
dir_mode = "0777"; backend_args = {
file_mode = "0777"; "-fstype" = "fuse";
use_cache = "/tmp";
del_cache = null;
allow_other = null;
url = "https://v5h5.la11.idrivee2-14.com";
passwd_file = config.age.secrets."s3fs.digital-garden".path;
dbglevel = "debug"; # enable this for better debugging info in journalctl
uid = "1000"; # default user
gid = "100"; # users
umask = "003"; # others read only, fully shared for users group
}; };
in "felia_d ${confToBackendArg args} ://felia.coati-celsius.ts.net/d" bucket = "digital-garden";
) })
( (
let let
args = { args = {
"-fstype" = "cifs"; "-fstype" = "cifs";
credentials = config.age.secrets._nhitrl_cred.path; credentials = config.age.secrets._nhitrl_cred.path;
user = null; user = null;
uid = "1001"; uid = "1001";
gid = "100"; gid = "100";
dir_mode = "0777"; dir_mode = "0777";
file_mode = "0777"; file_mode = "0777";
}; };
in "felia_f ${confToBackendArg args} ://felia.coati-celsius.ts.net/f" in
) "felia_d ${confToBackendArg args} ://felia.coati-celsius.ts.net/d"
]; )
persoConf = pkgs.writeText "auto.personal" (builtins.concatStringsSep "\n" personalStorage); (
in { let
enable = true; args = {
# Creates /perso directory with every subdirectory declared by ${personalStorage} "-fstype" = "cifs";
# as of now (might be stale), /perso/hot is the only mount accessible credentials = config.age.secrets._nhitrl_cred.path;
# that is also managed by s3fs user = null;
autoMaster = '' uid = "1001";
/perso file:${persoConf} gid = "100";
''; dir_mode = "0777";
timeout = 30; # default: 600, 600 seconds (10 mins) of inactivity => unmount file_mode = "0777";
# debug = true; # writes to more to journalctl };
}; in
"felia_f ${confToBackendArg args} ://felia.coati-celsius.ts.net/f"
)
];
persoConf = pkgs.writeText "auto.personal" (builtins.concatStringsSep "\n" personalStorage);
in
{
enable = true;
# Creates /perso directory with every subdirectory declared by ${personalStorage}
# as of now (might be stale), /perso/hot is the only mount accessible
# that is also managed by s3fs
autoMaster = ''
/perso file:${persoConf}
'';
timeout = 30; # default: 600, 600 seconds (10 mins) of inactivity => unmount
# debug = true; # writes to more to journalctl
};
} }

View File

@ -1,25 +1,22 @@
{ { pkgs
pkgs, , config
config, , lib
lib, , ...
... }: let cfg = config.mod.tailscale; in {
}: let options.mod.tailscale = {
cfg = config.mod.tailscale;
in {
options.mod.tailscale = {
enable = lib.mkEnableOption "tailscale"; enable = lib.mkEnableOption "tailscale";
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [pkgs.tailscale]; environment.systemPackages = [ pkgs.tailscale ];
services.tailscale.enable = true; services.tailscale.enable = true;
systemd.services.tailscale-autoconnect = { systemd.services.tailscale-autoconnect = {
description = "Automatically connects to Tailscale"; description = "Automatically connects to Tailscale";
# make sure tailscale is running before trying to connect to tailscale # make sure tailscale is running before trying to connect to tailscale
after = ["network-pre.target" "tailscale.service"]; after = [ "network-pre.target" "tailscale.service" ];
wants = ["network-pre.target" "tailscale.service"]; wants = [ "network-pre.target" "tailscale.service" ];
wantedBy = ["multi-user.target"]; wantedBy = [ "multi-user.target" ];
# set this service as a oneshot job # set this service as a oneshot job
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
@ -36,7 +33,7 @@ in {
# ${pkgs.tailscale}/bin/tailscale up # blocks, doesn't give url # ${pkgs.tailscale}/bin/tailscale up # blocks, doesn't give url
# This time, configure device auth so that we authenticate from portal # This time, configure device auth so that we authenticate from portal
# https://tailscale.com/kb/1099/device-authorization/#enable-device-authorization-for-your-network # https://tailscale.com/kb/1099/device-authorization/#enable-device-authorization-for-your-network
${pkgs.tailscale}/bin/tailscale up -authkey tskey-auth-kJcgTG5CNTRL-PUVFkk31z1bThHpfq3FC5b1jcMmkW2EYW ${pkgs.tailscale}/bin/tailscale up -authkey tskey-auth-kJcgTG5CNTRL-PUVFkk31z1bThHpfq3FC5b1jcMmkW2EYW
''; '';
}; };

View File

@ -1,4 +1,4 @@
{config, ...}: { { config, ... }: {
networking.wireless.enable = true; networking.wireless.enable = true;
networking.wireless.environmentFile = config.age.secrets."wifi.env"; networking.wireless.environmentFile = config.age.secrets."wifi.env";
networking.wireless.networks = { networking.wireless.networks = {

View File

@ -5,13 +5,8 @@ Contains all configurations that are written in their native configuration langu
## Why native language? ## Why native language?
- Easier portability - Easier portability
- Syntax highlighting and robust checking without needing to realize derivation
- Nix can read from [JSON](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fromJSON), - Nix can read from [JSON](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fromJSON),
[TOML](https://nixos.org/manual/nix/stable/release-notes/rl-2.6.html#release-26-2022-01-24). [TOML](https://nixos.org/manual/nix/stable/release-notes/rl-2.6.html#release-26-2022-01-24).
- We have also managed to hack together a [fromYaml](./../nix-conf/lib/serde/default.nix), - We have also managed to hack together a [fromYaml](./../nix-conf/lib/serde/default.nix),
though it will not work for strictly pure builds or bootstrapping builds. though it will not work for strictly pure builds or bootstrapping builds.
## When to use Nix to generate config?
- Original configuraiton language requires too much duplication that can be solved with Nix

View File

@ -104,7 +104,7 @@ WPlug('kyazdani42/nvim-web-devicons') -- icons for folder and filetype
WPlug('m-demare/hlargs.nvim') -- highlights arguments; great for func prog WPlug('m-demare/hlargs.nvim') -- highlights arguments; great for func prog
WPlug('folke/todo-comments.nvim') -- Highlights TODO WPlug('folke/todo-comments.nvim') -- Highlights TODO
WPlug('NvChad/nvim-colorizer.lua') -- color highlighter with tailwind support WPlug('NvChad/nvim-colorizer.lua') -- color highlighter with tailwind support
WPlug('roobert/tailwindcss-colorizer-cmp.nvim') -- color for tailiwnd for compe WPlug('roobert/tailwindcss-colorizer-cmp.nvim') -- color highlighter with tailwind support
-- other utilities -- other utilities
WPlug('nvim-treesitter/nvim-treesitter-context') -- Top one-liner context of func/class scope WPlug('nvim-treesitter/nvim-treesitter-context') -- Top one-liner context of func/class scope
@ -112,7 +112,6 @@ WPlug('nvim-treesitter/playground') -- Sees Treesitter AST - less h
WPlug('saadparwaiz1/cmp_luasnip') -- snippet engine WPlug('saadparwaiz1/cmp_luasnip') -- snippet engine
WPlug('L3MON4D3/LuaSnip') -- snippet engine WPlug('L3MON4D3/LuaSnip') -- snippet engine
WPlug('mickael-menu/zk-nvim') -- Zettelkasten WPlug('mickael-menu/zk-nvim') -- Zettelkasten
WPlug('folke/neodev.nvim') -- Neovim + lua development setup
-- Switch cases: -- Switch cases:
-- `gsp` -> PascalCase (classes), `gsc` -> camelCase (Java), `gs_` -> snake_case (C/C++/Rust) -- `gsp` -> PascalCase (classes), `gsc` -> camelCase (Java), `gs_` -> snake_case (C/C++/Rust)
-- `gsu` -> UPPER_CASE (CONSTs), `gsk` -> kebab-case (Clojure), `gsK` -> Title-Kebab-Case -- `gsu` -> UPPER_CASE (CONSTs), `gsk` -> kebab-case (Clojure), `gsK` -> Title-Kebab-Case
@ -242,57 +241,7 @@ colorscheme gruvbox
]]) ]])
require('hlargs').setup() require('hlargs').setup()
require('nvim-web-devicons').setup() require('nvim-web-devicons').setup()
require('trouble').setup { require('trouble').setup()
position = "bottom", -- position of the list can be: bottom, top, left, right
height = 10, -- height of the trouble list when position is top or bottom
width = 50, -- width of the list when position is left or right
icons = true, -- use devicons for filenames
mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT
fold_open = "", -- icon used for open folds
fold_closed = "", -- icon used for closed folds
group = true, -- group results by file
padding = true, -- add an extra new line on top of the list
action_keys = {
-- key mappings for actions in the trouble list
-- map to {} to remove a mapping, for example:
-- close = {},
close = "q", -- close the list
cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
refresh = "r", -- manually refresh
jump = { "<cr>", "<tab>" }, -- jump to the diagnostic or open / close folds
open_split = { "<c-x>" }, -- open buffer in new split
open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
open_tab = { "<c-t>" }, -- open buffer in new tab
jump_close = { "o" }, -- jump to the diagnostic and close the list
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
switch_severity = "s", -- switch "diagnostics" severity filter level to HINT / INFO / WARN / ERROR
toggle_preview = "P", -- toggle auto_preview
hover = "K", -- opens a small popup with the full multiline message
preview = "p", -- preview the diagnostic location
close_folds = { "zM", "zm" }, -- close all folds
open_folds = { "zR", "zr" }, -- open all folds
toggle_fold = { "zA", "za" }, -- toggle fold of current file
previous = "k", -- previous item
next = "j" -- next item
},
indent_lines = true, -- add an indent guide below the fold icons
auto_open = false, -- automatically open the list when you have diagnostics
auto_close = false, -- automatically close the list when you have no diagnostics
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
auto_fold = false, -- automatically fold a file trouble list at creation
auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result
signs = {
-- icons / text used for a diagnostic
error = "",
warning = "",
hint = "",
information = "",
other = "",
},
use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client
}
-- TODO: Any way to collect all the TODOs and its variants? -- TODO: Any way to collect all the TODOs and its variants?
require('todo-comments').setup() require('todo-comments').setup()
@ -973,10 +922,10 @@ require('mason-lspconfig').setup_handlers({
defaultConfig = { defaultConfig = {
indent_style = "space", indent_style = "space",
indent_size = 4, indent_size = 4,
}, }
}, }
}, }
}, }
} }
end, end,
["pyright"] = function() ["pyright"] = function()
@ -1044,29 +993,6 @@ require('mason-lspconfig').setup_handlers({
}, },
} }
end, end,
["nil_ls"] = function()
require('lspconfig').nil_ls.setup {
on_attach = on_attach,
capabilities = capabilities,
--- refer to https://github.com/oxalica/nil/blob/main/docs/configuration.md
--- for the list of configurations available for `nil_ls`
settings = {
["nil"] = {
formatting = {
command = { "nix", "run", "nixpkgs#alejandra" },
},
nix = {
flake = {
-- calls `nix flake archive` to put a flake and its output to store
autoArchive = true,
-- auto eval flake inputs for improved completion
autoEvalInputs = true,
},
},
},
},
}
end,
}) })
require("rust-tools").setup { require("rust-tools").setup {
tools = { tools = {

View File

@ -1,51 +1,53 @@
{ { config
config, , proj_root
proj_root, , myLib
myLib, , ...
... }:
}: let let
inherit (myLib) fromYaml; inherit (myLib) fromYaml;
actualConfig = fromYaml (builtins.readFile "${proj_root.config.path}//alacritty/alacritty.yml"); actualConfig = fromYaml (builtins.readFile "${proj_root.config.path}//alacritty/alacritty.yml");
cfg = config.base.alacritty; cfg = config.base.alacritty;
in { in
options.base.alacritty = { {
font.family = myLib.mkOption { options.base.alacritty =
type = myLib.types.singleLineStr; {
default = actualConfig.font.normal.family; font.family = myLib.mkOption {
description = '' type = myLib.types.singleLineStr;
The font family for Alacritty default = actualConfig.font.normal.family;
''; description = ''
example = "DroidSansMono NF"; The font family for Alacritty
'';
example = "DroidSansMono NF";
};
font.size = myLib.mkOption {
type = myLib.types.number;
default = actualConfig.font.size;
description = ''
The default font size for Alacritty. This is probably measured in px.
'';
example = 7.0;
};
enable = myLib.mkOption {
type = myLib.types.bool;
default = true;
description = ''
Enables alacritty
'';
example = true;
};
_actualConfig = myLib.mkOption {
type = myLib.types.attrs;
visible = false;
default = actualConfig;
description = "underlying default config";
};
additionalConfigPath = myLib.mkOption {
type = myLib.types.nullOr myLib.types.path;
visible = false;
default = null;
description = "impurely write our alacritty.yml to this path";
};
}; };
font.size = myLib.mkOption {
type = myLib.types.number;
default = actualConfig.font.size;
description = ''
The default font size for Alacritty. This is probably measured in px.
'';
example = 7.0;
};
enable = myLib.mkOption {
type = myLib.types.bool;
default = true;
description = ''
Enables alacritty
'';
example = true;
};
_actualConfig = myLib.mkOption {
type = myLib.types.attrs;
visible = false;
default = actualConfig;
description = "underlying default config";
};
additionalConfigPath = myLib.mkOption {
type = myLib.types.nullOr myLib.types.path;
visible = false;
default = null;
description = "impurely write our alacritty.yml to this path";
};
};
config.programs.alacritty = { config.programs.alacritty = {
enable = cfg.enable; enable = cfg.enable;

View File

@ -1,29 +1,25 @@
{ lib, pkgs, config, ... }:
{ {
lib,
pkgs,
config,
...
}: {
# This patch exists since Darwin's search bar requires solid apps and not # This patch exists since Darwin's search bar requires solid apps and not
# symlinked # symlinked
# TODO: QA # TODO: QA
# - [x] works for base case # - [x] works for base case
# - [x] works for repeated case # - [x] works for repeated case
# - [ ] works after base case, then removed # - [ ] works after base case, then removed
# - [ ] works for repeated case, then removed # - [ ] works for repeated case, then removed
# Copy GUI apps to "~/Applications/Home Manager Apps" # Copy GUI apps to "~/Applications/Home Manager Apps"
# Based on this comment: https://github.com/nix-community/home-manager/issues/1341#issuecomment-778820334 # Based on this comment: https://github.com/nix-community/home-manager/issues/1341#issuecomment-778820334
home.activation.patch-spotlight = home.activation.patch-spotlight =
if pkgs.stdenv.isDarwin if pkgs.stdenv.isDarwin then
then let let
apps = pkgs.buildEnv { apps = pkgs.buildEnv {
name = "home-manager-applications"; name = "home-manager-applications";
paths = config.home.packages; paths = config.home.packages;
pathsToLink = "/Applications"; pathsToLink = "/Applications";
}; };
in in
lib.hm.dag.entryAfter ["linkGeneration"] '' lib.hm.dag.entryAfter [ "linkGeneration" ] ''
# Install MacOS applications to the user environment. # Install MacOS applications to the user environment.
HM_APPS="$HOME/Applications/Home Manager Apps" HM_APPS="$HOME/Applications/Home Manager Apps"
# Reset current state # Reset current state
@ -37,18 +33,19 @@
$DRY_RUN_CMD cp --archive -H --dereference ${apps}/Applications/* "$HM_APPS" $DRY_RUN_CMD cp --archive -H --dereference ${apps}/Applications/* "$HM_APPS"
$DRY_RUN_CMD chmod +w -R "$HM_APPS" $DRY_RUN_CMD chmod +w -R "$HM_APPS"
'' ''
else ""; else
"";
# We need this in case upstream home-manager changes the behavior of linking # We need this in case upstream home-manager changes the behavior of linking
# applications # applications
home.activation.remove-patch-spotlight = home.activation.remove-patch-spotlight =
if pkgs.stdenv.isDarwin if pkgs.stdenv.isDarwin then
then lib.hm.dag.entryBefore [ "checkLinkTargets" ] ''
lib.hm.dag.entryBefore ["checkLinkTargets"] ''
HM_APPS="$HOME/Applications/Home Manager Apps" HM_APPS="$HOME/Applications/Home Manager Apps"
# Reset current state # Reset current state
if [ -e "$HM_APPS" ]; then if [ -e "$HM_APPS" ]; then
$DRY_RUN_CMD mv "$HM_APPS" "$HM_APPS.$(date +%Y%m%d%H%M%S)" $DRY_RUN_CMD mv "$HM_APPS" "$HM_APPS.$(date +%Y%m%d%H%M%S)"
fi fi
'' ''
else ""; else
"";
} }

View File

@ -1,4 +1,6 @@
{nix-index-database, ...} @ inputs: { {nix-index-database
,...
}@inputs:{
mkModuleArgs = import ./mkModuleArgs.nix; mkModuleArgs = import ./mkModuleArgs.nix;
modules = [ modules = [
./alacritty.nix ./alacritty.nix

View File

@ -1,8 +1,8 @@
{ { config
config, , myLib
myLib, , ...
... }:
}: let let
cfg = config.base.git; cfg = config.base.git;
baseAliases = { baseAliases = {
a = "add"; a = "add";
@ -15,11 +15,12 @@
co = "checkout"; co = "checkout";
b = "branch"; b = "branch";
}; };
in { in
{
options.base.git = { options.base.git = {
aliases = myLib.mkOption { aliases = myLib.mkOption {
type = myLib.types.attrs; type = myLib.types.attrs;
default = {}; default = { };
example = baseAliases; example = baseAliases;
description = '' description = ''
Additional git aliases. This settings comes with base configuration. Additional git aliases. This settings comes with base configuration.
@ -49,7 +50,7 @@ in {
.gitignore patterns that are applied in every repository. .gitignore patterns that are applied in every repository.
This is useful for IDE-specific settings. This is useful for IDE-specific settings.
''; '';
example = [".direnv" "node_modules"]; example = [ ".direnv" "node_modules" ];
}; };
enable = myLib.mkOption { enable = myLib.mkOption {
type = myLib.types.bool; type = myLib.types.bool;

View File

@ -1,14 +1,11 @@
{ { pkgs, config, lib, ... }:
pkgs, let
config,
lib,
...
}: let
cfg = config.base.graphics; cfg = config.base.graphics;
cfgEnable = cfg.enable or (cfg.useNixGL.defaultPackage != null); cfgEnable = cfg.enable or (cfg.useNixGL.defaultPackage != null);
types = lib.types; types = lib.types;
in { in
imports = [./shells.nix]; {
imports = [ ./shells.nix ];
options.base.graphics = { options.base.graphics = {
enable = lib.mkEnableOption "graphics"; enable = lib.mkEnableOption "graphics";
_enable = lib.mkOption { _enable = lib.mkOption {
@ -26,7 +23,7 @@ in {
]; ];
}; };
defaultPackage = lib.mkOption { defaultPackage = lib.mkOption {
type = types.nullOr (types.enum ["nixGLIntel" "nixGLNvidia" "nixGLNvidiaBumblebee"]); type = types.nullOr (types.enum [ "nixGLIntel" "nixGLNvidia" "nixGLNvidiaBumblebee" ]);
description = "Which nixGL package to be aliased as `nixGL` on the shell"; description = "Which nixGL package to be aliased as `nixGL` on the shell";
default = null; default = null;
example = "nixGLIntel"; example = "nixGLIntel";
@ -44,6 +41,6 @@ in {
nixGL = cfg.useNixGL.defaultPackage; nixGL = cfg.useNixGL.defaultPackage;
}; };
}; };
home.packages = [cfg.useNixGL.package]; home.packages = [ cfg.useNixGL.package ];
}; };
} }

View File

@ -1,14 +1,10 @@
{ { config, proj_root, pkgs, lib, ... }:
config, let
proj_root,
pkgs,
lib,
...
}: let
cfg = config.base.keepass; cfg = config.base.keepass;
trimNull = lib.filterAttrsRecursive (name: value: value != null); trimNull = lib.filterAttrsRecursive (name: value: value != null);
in { in
imports = [./graphics.nix]; {
imports = [ ./graphics.nix ];
options.base.keepass = { options.base.keepass = {
enable = lib.mkEnableOption "keepass"; enable = lib.mkEnableOption "keepass";
use_gui = lib.mkOption { use_gui = lib.mkOption {
@ -46,18 +42,12 @@ in {
}; };
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = home.packages = [
[ pkgs.kpcli-py # kp but is in cli
pkgs.kpcli-py # kp but is in cli ] ++ (if cfg.use_gui or config.base.graphics._enable then [
] pkgs.keepass # Personal secret management
++ ( ] else [ ]);
if cfg.use_gui or config.base.graphics._enable home.file.".kp/config.ini".text = lib.generators.toINI { } (trimNull {
then [
pkgs.keepass # Personal secret management
]
else []
);
home.file.".kp/config.ini".text = lib.generators.toINI {} (trimNull {
default = { default = {
KEEPASSDB = cfg.path; KEEPASSDB = cfg.path;
KEEPASSDB_KEYFILE = cfg.keyfile_path; KEEPASSDB_KEYFILE = cfg.keyfile_path;

View File

@ -1,20 +1,20 @@
# Turns given inputs into the standardized shape of the inputs to configure # Turns given inputs into the standardized shape of the inputs to configure
# custom base modules in this directory. # custom base modules in this directory.
{ { pkgs
pkgs, , lib ? pkgs.lib
lib ? pkgs.lib, , ...
... }@inputs:
} @ inputs: let let
recursiveUpdate = lib.recursiveUpdate; recursiveUpdate = lib.recursiveUpdate;
_lib = recursiveUpdate lib (import ../../lib {inherit pkgs lib;}); _lib = recursiveUpdate lib (import ../../lib { inherit pkgs lib; });
proj_root = builtins.toString ./../../..; proj_root = builtins.toString ./../../..;
in in
# TODO: Unpollute inputs # TODO: Unpollute inputs
recursiveUpdate inputs { recursiveUpdate inputs {
proj_root = { proj_root = {
path = proj_root; path = proj_root;
config.path = "${proj_root}/native_configs"; config.path = "${proj_root}/native_configs";
scripts.path = "${proj_root}/scripts"; scripts.path = "${proj_root}/scripts";
}; };
myLib = _lib; myLib = _lib;
} }

View File

@ -2,86 +2,68 @@
# #
# One thing to consider, though, /nix/store of `nix-shell` or `nix-develop` # One thing to consider, though, /nix/store of `nix-shell` or `nix-develop`
# might be different from `home-manager`'s (~/.nix_profile/bin/jq) # might be different from `home-manager`'s (~/.nix_profile/bin/jq)
{ { pkgs, lib, config, proj_root, ... }:
pkgs, let
lib,
config,
proj_root,
...
}: let
# NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace # NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace
# and is added to the path after wrapping. # and is added to the path after wrapping.
# check: nix repl `homeConfigurations.hungtr.config.programs.neovim.finalPackage.buildCommand` # check: nix repl `homeConfigurations.hungtr.config.programs.neovim.finalPackage.buildCommand`
# see: :/--suffix.*PATH # see: :/--suffix.*PATH
# there should be mentions of additional packages # there should be mentions of additional packages
my_neovim = pkgs.neovim-unwrapped; my_neovim = pkgs.neovim-unwrapped;
rust_pkgs = rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith
pkgs.rust-bin.selectLatestNightlyWith
( (
toolchain: toolchain:
toolchain.default.override { toolchain.default.override {
extensions = ["rust-src" "rust-analyzer" "rust-docs" "rustfmt" "clippy" "miri"]; extensions = [ "rust-src" "rust-analyzer" "rust-docs" "rustfmt" "clippy" "miri" ];
} }
); ));
nvim_pkgs = nvim_pkgs = [
# pkgs.gccStdenv
pkgs.tree-sitter
pkgs.fzf # file name fuzzy search
pkgs.ripgrep # content fuzzy search
pkgs.zk # Zettelkasten (limited support)
pkgs.fd # Required by a Telescope plugin (?)
pkgs.stdenv.cc.cc.lib
pkgs.rnix-lsp # doesn't work, Mason just installs it using cargo
pkgs.rust4cargo
pkgs.nickel
pkgs.nls
pkgs.go # doesn't work, Mason installs from runtime path
# Language-specific stuffs
pkgs.sumneko-lua-language-server
# pkgs.python3Packages.python-lsp-server
pkgs.nodePackages.pyright
pkgs.python3Packages.pylint
pkgs.python3Packages.flake8
# FIXME: installing ansible from here just doesn't work :/
# pkgs.ansible-lint
# pkgs.python38Packages.ansible
# pkgs.ansible-language-server
# TODO: the devShell should provide rust-analyzer so that
# cargo test builds binaries compatible with rust-analyzer
# pkgs.rust-analyzer
# rust_pkgs
# pkgs.evcxr # Rust REPL for Conjure!
] ++ lib.optionals (pkgs.stdenv.isDarwin) (
let
inherit (pkgs.darwin.apple_sdk.frameworks) System CoreFoundation; in
[ [
# pkgs.gccStdenv System
pkgs.tree-sitter CoreFoundation
pkgs.fzf # file name fuzzy search
pkgs.ripgrep # content fuzzy search
pkgs.zk # Zettelkasten (limited support)
pkgs.fd # Required by a Telescope plugin (?)
pkgs.stdenv.cc.cc.lib
pkgs.rnix-lsp # doesn't work, Mason just installs it using cargo
pkgs.rust4cargo
pkgs.nickel
pkgs.nls
pkgs.go # doesn't work, Mason installs from runtime path
# Language-specific stuffs
pkgs.sumneko-lua-language-server
# pkgs.python3Packages.python-lsp-server
pkgs.nodePackages.pyright
pkgs.python3Packages.pylint
pkgs.python3Packages.flake8
# FIXME: installing ansible from here just doesn't work :/
# pkgs.ansible-lint
# pkgs.python38Packages.ansible
# pkgs.ansible-language-server
# TODO: the devShell should provide rust-analyzer so that
# cargo test builds binaries compatible with rust-analyzer
# pkgs.rust-analyzer
# rust_pkgs
# pkgs.evcxr # Rust REPL for Conjure!
] ]
++ lib.optionals (pkgs.stdenv.isDarwin) ( );
let in
inherit (pkgs.darwin.apple_sdk.frameworks) System CoreFoundation; {
in [
System
CoreFoundation
]
);
in {
options.base.neovim = { options.base.neovim = {
enable = lib.mkOption { enable = lib.mkOption {
default = true; default = true;
description = "enable personalized neovim as default editor"; description = "enable personalized neovim as default editor";
type = lib.types.bool; type = lib.types.bool;
example = false; example = false;
f = let
adder = {
__functor = self: arg:
if builtins.isInt arg
then self // {x = self.x + arg;}
else self.x;
x = 0;
};
in {
what = adder 1 2 3 {};
};
}; };
}; };
config = lib.mkIf config.base.neovim.enable { config = lib.mkIf config.base.neovim.enable {
@ -94,54 +76,60 @@ in {
withPython3 = true; withPython3 = true;
withNodeJs = true; withNodeJs = true;
extraPackages = nvim_pkgs; extraPackages = nvim_pkgs;
extraLuaConfig = builtins.readFile "${proj_root.config.path}//neovim/init.lua"; extraLuaConfig = (builtins.readFile "${proj_root.config.path}//neovim/init.lua");
plugins = let plugins = (let inherit (pkgs.vimPlugins)
inherit plenary-nvim
(pkgs.vimPlugins)
plenary-nvim nvim-treesitter
nvim-treesitter nvim-treesitter-textobjects
nvim-treesitter-textobjects nvim-treesitter-context
nvim-treesitter-context
telescope-fzf-native-nvim telescope-fzf-native-nvim
telescope-file-browser-nvim telescope-file-browser-nvim
telescope-nvim telescope-nvim
nvim-lspconfig
gruvbox-community nvim-lspconfig
neodev-nvim
cmp-nvim-lsp gruvbox-community
cmp-path
cmp-buffer neodev-nvim
cmp-cmdline
nvim-cmp cmp-nvim-lsp
lspkind-nvim cmp-path
nvim-autopairs cmp-buffer
nvim-ts-autotag cmp-cmdline
guess-indent-nvim nvim-cmp
harpoon
zk-nvim lspkind-nvim
luasnip nvim-autopairs
fidget-nvim nvim-ts-autotag
rust-tools-nvim guess-indent-nvim
cmp_luasnip harpoon
gitsigns-nvim zk-nvim
indent-blankline-nvim luasnip
lualine-nvim fidget-nvim
mason-lspconfig-nvim rust-tools-nvim
mason-nvim
neogit cmp_luasnip
nlua-nvim gitsigns-nvim
nvim-jqx indent-blankline-nvim
nvim-surround lualine-nvim
nvim-web-devicons mason-lspconfig-nvim
playground mason-nvim
todo-comments-nvim neogit
trouble-nvim nlua-nvim
vim-dispatch nvim-jqx
vim-dispatch-neovim nvim-surround
vim-fugitive nvim-web-devicons
vim-jack-in playground
; todo-comments-nvim
in [ trouble-nvim
vim-dispatch
vim-dispatch-neovim
vim-fugitive
vim-jack-in
; in [
plenary-nvim plenary-nvim
nvim-treesitter.withAllGrammars nvim-treesitter.withAllGrammars
nvim-treesitter-textobjects nvim-treesitter-textobjects
@ -184,8 +172,8 @@ in {
vim-dispatch vim-dispatch
vim-dispatch-neovim vim-dispatch-neovim
vim-fugitive vim-fugitive
vim-jack-in vim-jack-in
]; ]);
}; };
# home.packages = nvim_pkgs; # home.packages = nvim_pkgs;
}; };

View File

@ -1,13 +1,9 @@
# TODO: maybe throw if base.graphics is not enabled? # TODO: maybe throw if base.graphics is not enabled?
# Though, headless chromium might be possible # Though, headless chromium might be possible
{ config, pkgs, lib, ... }:
let cfg = config.base.private_chromium;
in
{ {
config,
pkgs,
lib,
...
}: let
cfg = config.base.private_chromium;
in {
options.base.private_chromium = { options.base.private_chromium = {
enable = lib.mkOption { enable = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
@ -23,36 +19,33 @@ in {
programs.chromium = { programs.chromium = {
enable = true; enable = true;
package = pkgs.ungoogled-chromium; package = pkgs.ungoogled-chromium;
extensions = let extensions =
# TODO: how about a chrome extension registry? let
mkChromiumExtForVersion = browserVersion: { # TODO: how about a chrome extension registry?
id, mkChromiumExtForVersion = browserVersion: { id, sha256, extVersion, ... }:
sha256, {
extVersion, inherit id;
... crxPath = builtins.fetchurl {
}: { url = "https://clients2.google.com/service/update2/crx" +
inherit id; "?response=redirect" +
crxPath = builtins.fetchurl { "&acceptformat=crx2,crx3" +
url = "&prodversion=${browserVersion}" +
"https://clients2.google.com/service/update2/crx" "&x=id%3D${id}%26installsource%3Dondemand%26uc";
+ "?response=redirect" name = "${id}.crx";
+ "&acceptformat=crx2,crx3" inherit sha256;
+ "&prodversion=${browserVersion}" };
+ "&x=id%3D${id}%26installsource%3Dondemand%26uc"; version = extVersion;
name = "${id}.crx"; };
inherit sha256; mkChromiumExt = mkChromiumExtForVersion (lib.versions.major pkgs.ungoogled-chromium.version);
}; in
version = extVersion; [
}; # vimium
mkChromiumExt = mkChromiumExtForVersion (lib.versions.major pkgs.ungoogled-chromium.version); (mkChromiumExt {
in [ id = "dbepggeogbaibhgnhhndojpepiihcmeb";
# vimium sha256 = "00qhbs41gx71q026xaflgwzzridfw1sx3i9yah45cyawv8q7ziic";
(mkChromiumExt { extVersion = "1.67.4";
id = "dbepggeogbaibhgnhhndojpepiihcmeb"; })
sha256 = "00qhbs41gx71q026xaflgwzzridfw1sx3i9yah45cyawv8q7ziic"; ];
extVersion = "1.67.4";
})
];
}; };
}; };
} }

View File

@ -1,9 +1,9 @@
# A module that takes care of a GUI-ful, productive desktop environment # A module that takes care of a GUI-ful, productive desktop environment
inputs @ {pkgs, ...}: { inputs@{ pkgs, ... }: {
imports = [ imports = [
# slack # slack
({pkgs, ...}: { ({ pkgs, ... }: {
home.packages = [ home.packages = [
pkgs.slack pkgs.slack
]; ];
}) })

View File

@ -1,14 +1,14 @@
# Configurations for shell stuffs. # Configurations for shell stuffs.
# Should probably be decoupled even more for each feature # Should probably be decoupled even more for each feature
{ config
, proj_root
, myLib
, pkgs
, ...
}:
let cfg = config.base.shells;
in
{ {
config,
proj_root,
myLib,
pkgs,
...
}: let
cfg = config.base.shells;
in {
options.base.shells = { options.base.shells = {
enable = myLib.mkOption { enable = myLib.mkOption {
type = myLib.types.bool; type = myLib.types.bool;
@ -30,7 +30,7 @@ in {
shellAliases = myLib.mkOption { shellAliases = myLib.mkOption {
type = myLib.types.attrs; type = myLib.types.attrs;
description = "Shell command aliases"; description = "Shell command aliases";
default = {}; default = { };
example = { example = {
nixGL = "nixGLIntel"; nixGL = "nixGLIntel";
}; };
@ -52,8 +52,8 @@ in {
programs.tmux = { programs.tmux = {
enable = true; enable = true;
# extraConfigBeforePlugin = builtins.readFile "${proj_root.config.path}/tmux/tmux.conf"; # extraConfigBeforePlugin = builtins.readFile "${proj_root.config.path}/tmux/tmux.conf";
plugins = let inherit (pkgs.tmuxPlugins) cpu net-speed; in [cpu net-speed]; plugins = let inherit (pkgs.tmuxPlugins) cpu net-speed; in [ cpu net-speed ];
extraConfig = builtins.readFile "${proj_root.config.path}/tmux/tmux.conf"; extraConfig = (builtins.readFile "${proj_root.config.path}/tmux/tmux.conf");
}; };
xdg.configFile."tmux/tmux.conf".text = myLib.mkOrder 600 '' xdg.configFile."tmux/tmux.conf".text = myLib.mkOrder 600 ''
set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M ' set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M '
@ -67,16 +67,15 @@ in {
programs.starship = { programs.starship = {
enable = true; enable = true;
enableZshIntegration = true; enableZshIntegration = true;
settings = let settings = let
native = builtins.fromTOML (builtins.readFile "${proj_root.config.path}/starship/starship.toml"); native = builtins.fromTOML (builtins.readFile "${proj_root.config.path}/starship/starship.toml");
patch-nix = pkgs.lib.recursiveUpdate native { patch-nix = pkgs.lib.recursiveUpdate native ({
c.commands = [ c.commands = [
["nix" "run" "nixpkgs#clang" "--" "--version"] ["nix" "run" "nixpkgs#clang" "--" "--version"]
["nix" "run" "nixpkgs#gcc" "--" "--version"] ["nix" "run" "nixpkgs#gcc" "--" "--version"]
]; ];
}; });
in in patch-nix;
patch-nix;
}; };
# Fuzzy finder. `fzf` for TUI, `fzf -f '<fuzzy query>'` for UNIX piping # Fuzzy finder. `fzf` for TUI, `fzf -f '<fuzzy query>'` for UNIX piping
programs.fzf.enable = true; programs.fzf.enable = true;
@ -89,12 +88,10 @@ in {
enable = true; enable = true;
enableCompletion = true; enableCompletion = true;
enableAutosuggestions = true; enableAutosuggestions = true;
shellAliases = shellAliases = {
{ nix-rebuild = "sudo nixos-rebuild switch";
nix-rebuild = "sudo nixos-rebuild switch"; hm-switch = "home-manager switch --flake";
hm-switch = "home-manager switch --flake"; } // (cfg.shellAliases or { });
}
// (cfg.shellAliases or {});
history = { history = {
size = 10000; size = 10000;
path = "${config.xdg.dataHome}/zsh/history"; path = "${config.xdg.dataHome}/zsh/history";
@ -122,11 +119,10 @@ in {
ZVM_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :) ZVM_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :)
ZVM_ESCAPE_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :) ZVM_ESCAPE_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :)
}; };
initExtra = initExtra = (cfg.shellInitExtra or "") + ''
(cfg.shellInitExtra or "") source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
+ '' '';
source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
'';
}; };
}; };
} }

View File

@ -1,11 +1,11 @@
{ config
, proj_root
, myLib
, ...
}:
let cfg = config.base.ssh;
in
{ {
config,
proj_root,
myLib,
...
}: let
cfg = config.base.ssh;
in {
options.base.ssh.enable = myLib.mkOption { options.base.ssh.enable = myLib.mkOption {
type = myLib.types.bool; type = myLib.types.bool;
default = true; default = true;
@ -20,3 +20,4 @@ in {
includes = ["${proj_root.config.path}/ssh/config"]; includes = ["${proj_root.config.path}/ssh/config"];
}; };
} }

View File

@ -1,13 +1,11 @@
# We use top-level nix-flake, so default.nix is basically just a wrapper around ./flake.nix # We use top-level nix-flake, so default.nix is basically just a wrapper around ./flake.nix
( (import
import
( (
let let
lock = builtins.fromJSON (builtins.readFile ./flake.lock); lock = builtins.fromJSON (builtins.readFile ./flake.lock);
c_ = import ./../../c_.nix; c_ = import ./../../c_.nix;
in in
c_.fetchTree lock.nodes.flake-compat.locked c_.fetchTree lock.nodes.flake-compat.locked
) )
{src = ./.;} { src = ./.; }
) ).defaultNix
.defaultNix

View File

@ -833,11 +833,11 @@
}, },
"nixpkgs-latest": { "nixpkgs-latest": {
"locked": { "locked": {
"lastModified": 1687044368, "lastModified": 1686940302,
"narHash": "sha256-7eBtV3lgfgjeyBDa20Xr4O9mlcAHHFYpvo6m16tgLcY=", "narHash": "sha256-hTBVlV53sfi7ZyTkRKIVZy3V26ixnWGZnYrHvb9rCZU=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "b621273236ab985db5ff7e91171624f2e07e82a1", "rev": "1f5b5df0d309144d10d409d161b50adc94157ef6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -882,11 +882,11 @@
}, },
"nixpkgs_10": { "nixpkgs_10": {
"locked": { "locked": {
"lastModified": 1686960236, "lastModified": 1686869522,
"narHash": "sha256-AYCC9rXNLpUWzD9hm+askOfpliLEC9kwAo7ITJc4HIw=", "narHash": "sha256-tbJ9B8WLCTnVP/LwESRlg0dII6Zyg2LmUU/mB9Lu98E=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "04af42f3b31dba0ef742d254456dc4c14eedac86", "rev": "7c67f006ea0e7d0265f16d7df07cc076fdffd91f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -1327,11 +1327,11 @@
"nixpkgs": "nixpkgs_11" "nixpkgs": "nixpkgs_11"
}, },
"locked": { "locked": {
"lastModified": 1686968542, "lastModified": 1686882360,
"narHash": "sha256-Gjlj7UeHqMFRAYyefeoLnSjLo8V+0XheIamojNEyTbE=", "narHash": "sha256-6iWVGIdIzmx/CgXPVLPyyxxBhPGYMl8sG09S8hpQ6pc=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "01d84cd842e48e89be67e4c2d9dc46aa7709adc5", "rev": "b519b1d7a31f1bd35423990398adecc6f7dd4dd2",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -43,88 +43,82 @@
}; };
}; };
outputs = flake_inputs @ { outputs =
nixpkgs, flake_inputs@{ nixpkgs
home-manager, , home-manager
nixgl, , nixgl
rust-overlay, , rust-overlay
flake-utils, , flake-utils
kpcli-py, , kpcli-py
neovim-nightly-overlay, , neovim-nightly-overlay
nix-boost, , nix-boost
nixpkgs-latest, , nixpkgs-latest
... , ...
}: let }:
# config_fn:: system -> config let
cross_platform = config_fn: { # config_fn:: system -> config
packages = cross_platform = config_fn: ({
builtins.foldl' packages = builtins.foldl'
(prev: system: (prev: system: prev // {
prev
// {
"${system}" = config_fn system; "${system}" = config_fn system;
}) })
{} { }
flake-utils.lib.defaultSystems; flake-utils.lib.defaultSystems;
}; });
in in
cross_platform (system: let cross_platform (system:
overlays = import ./overlays.nix (flake_inputs // {inherit system;}); let
overlays = import ./overlays.nix (flake_inputs // { inherit system; });
# pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays; # pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays;
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system overlays; inherit system overlays;
config = {allowUnfree = true;}; config = { allowUnfree = true; };
}; };
# lib = (import ../lib { inherit pkgs; lib = pkgs.lib; }); # lib = (import ../lib { inherit pkgs; lib = pkgs.lib; });
base = import ./base flake_inputs; base = import ./base flake_inputs;
inherit (base) mkModuleArgs; inherit (base) mkModuleArgs;
nerd_font_module = { nerd_font_module = { config, pkgs, ... }: {
config,
pkgs,
...
}: {
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
home.packages = [ home.packages = [
# list of fonts are available at https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/data/fonts/nerdfonts/shas.nix # list of fonts are available at https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/data/fonts/nerdfonts/shas.nix
(pkgs.nerdfonts.override {fonts = ["Hack"];}) (pkgs.nerdfonts.override { fonts = [ "Hack" ]; })
]; ];
base.alacritty.font.family = "Hack Nerd Font Mono"; base.alacritty.font.family = "Hack Nerd Font Mono";
}; };
in { in
{
debug = { debug = {
inherit overlays pkgs base; inherit overlays pkgs base;
}; };
homeConfigurations = let homeConfigurations =
x11_wsl = '' let
# x11 output for WSL x11_wsl = ''
export DISPLAY=$(ip route list default | awk '{print $3}'):0 # x11 output for WSL
export LIBGL_ALWAYS_INDIRECT=1 export DISPLAY=$(ip route list default | awk '{print $3}'):0
''; export LIBGL_ALWAYS_INDIRECT=1
in { '';
"hungtr" = home-manager.lib.homeManagerConfiguration { in
inherit pkgs; {
modules = "hungtr" = home-manager.lib.homeManagerConfiguration {
base.modules inherit pkgs;
++ [ modules = base.modules ++ [
./home.nix ./home.nix
]; ];
# optionally pass inarguments to module # optionally pass inarguments to module
# we migrate this from in-place modules to allow flexibility # we migrate this from in-place modules to allow flexibility
# in this case, we can add "home" to input arglist of home.nix # in this case, we can add "home" to input arglist of home.nix
extraSpecialArgs = mkModuleArgs { extraSpecialArgs = mkModuleArgs {
inherit pkgs; inherit pkgs;
myHome = { myHome = {
username = "hungtr"; username = "hungtr";
homeDirectory = "/home/hungtr"; homeDirectory = "/home/hungtr";
};
}; };
}; };
}; "hungtr@bao" = home-manager.lib.homeManagerConfiguration {
"hungtr@bao" = home-manager.lib.homeManagerConfiguration { inherit pkgs;
inherit pkgs; modules = base.modules ++ [
modules =
base.modules
++ [
./home.nix ./home.nix
nerd_font_module nerd_font_module
./base/productive_desktop.nix ./base/productive_desktop.nix
@ -137,23 +131,21 @@
base.graphics.useNixGL.enable = true; base.graphics.useNixGL.enable = true;
} }
]; ];
# optionally pass inarguments to module # optionally pass inarguments to module
# we migrate this from in-place modules to allow flexibility # we migrate this from in-place modules to allow flexibility
# in this case, we can add "home" to input arglist of home.nix # in this case, we can add "home" to input arglist of home.nix
extraSpecialArgs = mkModuleArgs { extraSpecialArgs = mkModuleArgs {
inherit pkgs; inherit pkgs;
myHome = { myHome = {
username = "hungtr"; username = "hungtr";
homeDirectory = "/home/hungtr"; homeDirectory = "/home/hungtr";
};
}; };
}; };
}; # Personal darwin, effectively serves as the Darwin edge channel
# Personal darwin, effectively serves as the Darwin edge channel "hungtran" = home-manager.lib.homeManagerConfiguration {
"hungtran" = home-manager.lib.homeManagerConfiguration { inherit pkgs;
inherit pkgs; modules = base.modules ++ [
modules =
base.modules
++ [
./home.nix ./home.nix
{ {
base.graphics.enable = false; base.graphics.enable = false;
@ -174,20 +166,18 @@
]; ];
} }
]; ];
extraSpecialArgs = mkModuleArgs { extraSpecialArgs = mkModuleArgs {
inherit pkgs; inherit pkgs;
myHome = { myHome = {
username = "hungtran"; username = "hungtran";
homeDirectory = "/Users/hungtran"; homeDirectory = "/Users/hungtran";
};
}; };
}; };
}; # Work darwin
# Work darwin "htran" = home-manager.lib.homeManagerConfiguration {
"htran" = home-manager.lib.homeManagerConfiguration { inherit pkgs;
inherit pkgs; modules = base.modules ++ [
modules =
base.modules
++ [
./home.nix ./home.nix
./base/productive_desktop.nix ./base/productive_desktop.nix
./base/darwin-spotlight.nix ./base/darwin-spotlight.nix
@ -208,46 +198,42 @@
pkgs.postman pkgs.postman
]; ];
} }
{base.keepass.enable = pkgs.lib.mkForce false;} { base.keepass.enable = pkgs.lib.mkForce false; }
]; ];
extraSpecialArgs = mkModuleArgs { extraSpecialArgs = mkModuleArgs {
inherit pkgs; inherit pkgs;
myHome = { myHome = {
username = "htran"; username = "htran";
homeDirectory = "/Users/htran"; homeDirectory = "/Users/htran";
};
};
};
"nixos@Felia" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
./home.nix
{
base.shells = {
shellInitExtra =
''
''
+ x11_wsl;
}; };
}
];
# optionally pass inarguments to module
# we migrate this from in-place modules to allow flexibility
# in this case, we can add "home" to input arglist of home.nix
extraSpecialArgs = mkModuleArgs {
inherit pkgs;
myHome = {
username = "nixos";
homeDirectory = "/home/nixos";
}; };
}; };
}; "nixos@Felia" = home-manager.lib.homeManagerConfiguration {
# Personal laptop inherit pkgs;
hwtr = home-manager.lib.homeManagerConfiguration { modules = [
inherit pkgs; ./home.nix
modules = {
base.modules base.shells = {
++ [ shellInitExtra = ''
'' + x11_wsl;
};
}
];
# optionally pass inarguments to module
# we migrate this from in-place modules to allow flexibility
# in this case, we can add "home" to input arglist of home.nix
extraSpecialArgs = mkModuleArgs {
inherit pkgs;
myHome = {
username = "nixos";
homeDirectory = "/home/nixos";
};
};
};
# Personal laptop
hwtr = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = base.modules ++ [
./home.nix ./home.nix
./base/graphics.nix ./base/graphics.nix
{ {
@ -258,17 +244,17 @@
./base/productive_desktop.nix ./base/productive_desktop.nix
]; ];
extraSpecialArgs = mkModuleArgs { extraSpecialArgs = mkModuleArgs {
inherit pkgs; inherit pkgs;
myHome = { myHome = {
username = "hwtr"; username = "hwtr";
homeDirectory = "/home/hwtr"; homeDirectory = "/home/hwtr";
packages = [ packages = [
pkgs.postman pkgs.postman
]; ];
};
}; };
}; };
}; };
};
}); });
} }

View File

@ -3,20 +3,18 @@
# This file represents the base settings for each machine # This file represents the base settings for each machine
# Additional configurations goes to profiles/<user> # Additional configurations goes to profiles/<user>
# or inlined in flake.nix # or inlined in flake.nix
{ { config # Represents the realized final configuration
config, , pkgs # This is by default just ``= import <nixpkgs>{}`
# Represents the realized final configuration , myHome
pkgs, , myLib
# This is by default just ``= import <nixpkgs>{}` , option # The options we're given, this might be useful for typesafety?
myHome, , proj_root
myLib, , ...
option, }:
# The options we're given, this might be useful for typesafety? let
proj_root,
...
}: let
inherit (myLib) fromYaml; inherit (myLib) fromYaml;
in { in
{
imports = [ imports = [
./base/neovim.nix ./base/neovim.nix
./base/keepass.nix ./base/keepass.nix
@ -26,41 +24,34 @@ in {
homeDirectory = myHome.homeDirectory; homeDirectory = myHome.homeDirectory;
stateVersion = myHome.stateVersion or "22.05"; stateVersion = myHome.stateVersion or "22.05";
}; };
home.packages = pkgs.lib.unique ( home.packages = pkgs.lib.unique ([
[ # pkgs.ncdu
# pkgs.ncdu pkgs.rclone # cloud file operations
pkgs.rclone # cloud file operations pkgs.htop # system diagnostics in CLI
pkgs.htop # system diagnostics in CLI pkgs.ripgrep # content fuzzy search
pkgs.ripgrep # content fuzzy search pkgs.unzip # compression
pkgs.unzip # compression pkgs.zip # compression
pkgs.zip # compression
# cool utilities # cool utilities
pkgs.yq-go # Yaml adaptor for jq (only pretty print, little query) pkgs.yq-go # Yaml adaptor for jq (only pretty print, little query)
# pkgs.xorg.xclock # TODO: only include if have gui # For testing GL installation # pkgs.xorg.xclock # TODO: only include if have gui # For testing GL installation
# pkgs.logseq # TODO: only include if have GL # Obsidian alt # pkgs.logseq # TODO: only include if have GL # Obsidian alt
pkgs.mosh # Parsec for SSH pkgs.mosh # Parsec for SSH
# pkgs.nixops_unstable # nixops v2 # insecure for now # pkgs.nixops_unstable # nixops v2 # insecure for now
pkgs.lynx # Web browser at your local terminal pkgs.lynx # Web browser at your local terminal
pkgs.zk pkgs.zk
# pkgs.tailscale # VPC;; This should be installed in system-nix # pkgs.tailscale # VPC;; This should be installed in system-nix
pkgs.python310 # dev packages should be in project pkgs.python310 # dev packages should be in project
# pkgs.python310.numpy # pkgs.python310.numpy
# pkgs.python310Packages.tensorflow # pkgs.python310Packages.tensorflow
# pkgs.python310Packages.scikit-learn # pkgs.python310Packages.scikit-learn
] ] ++ (myHome.packages or [ ]) ++ (if pkgs.system == "x86_64-linux" then [
++ (myHome.packages or []) pkgs.logseq
++ ( ] else [ ])
if pkgs.system == "x86_64-linux"
then [
pkgs.logseq
]
else []
)
); );
## Configs ## ## Configs ##
xdg.configFile."zk/config.toml".source = "${proj_root.config.path}//zk/config.toml"; xdg.configFile."zk/config.toml".source = "${proj_root.config.path}//zk/config.toml";
## Programs ## ## Programs ##

View File

@ -1,14 +1,14 @@
flake_input @ { flake_input@{ kpcli-py
kpcli-py, , nixgl
nixgl, , rust-overlay
rust-overlay, , neovim-nightly-overlay
neovim-nightly-overlay, , system
system, , nix-boost
nix-boost, , nixpkgs-latest
nixpkgs-latest, , ...
... }:
}: let let
kpcli-py = final: prev: { kpcli-py = (final: prev: {
# use python3.9, which works because of cython somehow? # use python3.9, which works because of cython somehow?
kpcli-py = final.poetry2nix.mkPoetryApplication { kpcli-py = final.poetry2nix.mkPoetryApplication {
projectDir = flake_input.kpcli-py; projectDir = flake_input.kpcli-py;
@ -16,12 +16,12 @@ flake_input @ {
# tableformatter requires setuptools # tableformatter requires setuptools
tableformatter = super.tableformatter.overridePythonAttrs ( tableformatter = super.tableformatter.overridePythonAttrs (
old: { old: {
buildInputs = (old.buildInputs or []) ++ [self.setuptools self.cython_3]; buildInputs = (old.buildInputs or [ ]) ++ [ self.setuptools self.cython_3 ];
src = old.src; src = old.src;
} }
); );
kpcli = super.kpcli.overridePythonAttrs (old: { kpcli = super.kpcli.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [self.setuptools]; buildInputs = (old.buildInputs or [ ]) ++ [ self.setuptools ];
}); });
# ubersmith = super.ubersmith.overridePythonAttrs (old: { # ubersmith = super.ubersmith.overridePythonAttrs (old: {
@ -37,30 +37,34 @@ flake_input @ {
# sha256 = "sha256-Dystt7CBtjpLkgzCsAif8WkkYYeLyh7VMehAtwoDGuM="; # sha256 = "sha256-Dystt7CBtjpLkgzCsAif8WkkYYeLyh7VMehAtwoDGuM=";
# }; # };
# }); # });
}); });
}; };
}; });
rust = final: prev: let rust = (final: prev:
nightlyRustWithExts = exts: let
final.rust-bin.selectLatestNightlyWith ( nightlyRustWithExts = exts: final.rust-bin.selectLatestNightlyWith (
toolchain: (toolchain.minimal.override { toolchain: (toolchain.minimal.override {
extensions = exts; extensions = exts;
}) })
); );
# https://rust-lang.github.io/rustup/concepts/profiles.html # https://rust-lang.github.io/rustup/concepts/profiles.html
rust-default-components = ["rust-docs" "rustfmt" "clippy"]; rust-default-components = [ "rust-docs" "rustfmt" "clippy" ];
rust-dev-components = rust-default-components ++ ["rust-src" "rust-analyzer" "miri"]; rust-dev-components = rust-default-components ++ [ "rust-src" "rust-analyzer" "miri" ];
in { in
rust4devs = nightlyRustWithExts rust-dev-components; {
rust4cargo = nightlyRustWithExts []; rust4devs = nightlyRustWithExts rust-dev-components;
rust4normi = nightlyRustWithExts rust-default-components; rust4cargo = nightlyRustWithExts [ ];
}; rust4normi = nightlyRustWithExts rust-default-components;
});
vimPlugins = final: prev: {
vimPlugins = (final: prev: {
inherit (nixpkgs-latest.legacyPackages.${system}) vimPlugins; inherit (nixpkgs-latest.legacyPackages.${system}) vimPlugins;
}; });
in [ in
[
nix-boost.overlays.default nix-boost.overlays.default
nixgl.overlays.default nixgl.overlays.default
rust-overlay.overlays.default rust-overlay.overlays.default

View File

@ -1,8 +1,5 @@
# main module exporter for different configuration profiles # main module exporter for different configuration profiles
{ pkgs, libs, ... } @ inputs:
{ {
pkgs,
libs,
...
} @ inputs: {
hwtr = import ./hwtr.nix; hwtr = import ./hwtr.nix;
} }

View File

@ -1,12 +1,12 @@
{ { pkgs
pkgs, , lib ? pkgs.lib
lib ? pkgs.lib, , ...
... }@flake_import:
} @ flake_import: let let
serde = import ./serde {inherit pkgs lib;}; serde = import ./serde { inherit pkgs lib; };
recursiveUpdate = lib.recursiveUpdate; recursiveUpdate = lib.recursiveUpdate;
in in
recursiveUpdate (recursiveUpdate pkgs.lib lib) { recursiveUpdate (recursiveUpdate pkgs.lib lib) {
fromYaml = serde.fromYaml; fromYaml = serde.fromYaml;
fromYamlPath = serde.fromYamlPath; fromYamlPath = serde.fromYamlPath;
} }

View File

@ -1,39 +1,31 @@
# Takes care of serializing and deserializing to some formats # Takes care of serializing and deserializing to some formats
# Blame: Pegasust<pegasucksgg@gmail.com> # Blame: Pegasust<pegasucksgg@gmail.com>
# TODO: Add to* formats from pkgs.formats.* # TODO: Add to* formats from pkgs.formats.*
{ { pkgs
pkgs, , lib
lib, } @ inputs:
} @ inputs: let let
yamlToJsonDrv = yamlContent: outputPath: yamlToJsonDrv = yamlContent: outputPath: pkgs.callPackage
pkgs.callPackage ({ runCommand }:
({runCommand}:
# runCommand source: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L33 # runCommand source: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L33
runCommand outputPath runCommand outputPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; }
{
inherit yamlContent;
nativeBuildInputs = [pkgs.yq];
}
# run yq which outputs '.' (no filter) on file at yamlPath # run yq which outputs '.' (no filter) on file at yamlPath
# note that $out is passed onto the bash/sh script for execution # note that $out is passed onto the bash/sh script for execution
'' ''
echo "$yamlContent" | yq >$out echo "$yamlContent" | yq >$out
'') '')
{}; { };
in { in
{
# Takes in a yaml string and produces a derivation with translated JSON at $outputPath # Takes in a yaml string and produces a derivation with translated JSON at $outputPath
# similar to builtins.fromJSON, turns a YAML string to nix attrset # similar to builtins.fromJSON, turns a YAML string to nix attrset
fromYaml = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv yamlContent "any_output.json")); fromYaml = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv yamlContent "any_output.json"));
fromYamlPath = yamlPath: fromYamlPath = yamlPath: builtins.fromJSON (
builtins.fromJSON ( builtins.readFile (
builtins.readFile ( yamlToJsonDrv
yamlToJsonDrv
( (
builtins.readFile yamlPath builtins.readFile yamlPath)
) "any-output.json"));
"any-output.json"
)
);
fromTOML = builtins.fromTOML; fromTOML = builtins.fromTOML;
fromJSON = builtins.fromJSON; fromJSON = builtins.fromJSON;
} }

View File

@ -1,12 +1,10 @@
# This module aims to be merge (not inject/override) with top-level pkgs to provide # This module aims to be merge (not inject/override) with top-level pkgs to provide
# personalized/custom packages # personalized/custom packages
{ { pkgs
pkgs, , lib
lib, , naersk # rust packages
naersk, , ...
# rust packages }@pkgs_input: {
...
} @ pkgs_input: {
# dot-hwtr = import "./dot-hwtr" pkgs_input; # dot-hwtr = import "./dot-hwtr" pkgs_input;
cargo-bacon = pkgs.rustPlatform.buildRustPackage rec { cargo-bacon = pkgs.rustPlatform.buildRustPackage rec {
pname = "bacon"; pname = "bacon";

View File

@ -4,12 +4,10 @@
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
naersk.url = "gihub:nix-community/naersk"; naersk.url = "gihub:nix-community/naersk";
}; };
outputs = { outputs = { nixpkgs, rust-overlay, naersk }:
nixpkgs, let
rust-overlay, pkgs = import nixpkgs { overlays = [ rust-overlay.overlays.default ]; };
naersk, lib = pkgs.lib;
}: let in
pkgs = import nixpkgs {overlays = [rust-overlay.overlays.default];}; (import ./default.nix { inherit pkgs lib naersk; });
lib = pkgs.lib;
in (import ./default.nix {inherit pkgs lib naersk;});
} }

View File

@ -10,8 +10,10 @@ let
all = users // systems; all = users // systems;
# stands for calculus # stands for calculus
c_ = builtins; c_ = builtins;
in { in
"system/secrets/s3fs.age".publicKeys = c_.attrValues all; {
"system/secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues all; "system/secrets/s3fs.age".publicKeys = c_.attrValues (all);
"system/secrets/_nhitrl.age".publicKeys = c_.attrValues all; "system/secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues (all);
"system/secrets/_nhitrl.age".publicKeys = c_.attrValues (all);
} }

View File

@ -1,71 +1,61 @@
{ { lib, pkgs, config, modulesPath, specialArgs, ... }:
lib, let
pkgs,
config,
modulesPath,
specialArgs,
...
}: let
hostname = specialArgs.hostname; hostname = specialArgs.hostname;
enableSSH = specialArgs.enableSSH or true; enableSSH = specialArgs.enableSSH or true;
_networking = lib.recursiveUpdate {hostName = hostname;} (specialArgs._networking or {}); _networking = lib.recursiveUpdate { hostName = hostname; } (specialArgs._networking or { });
_boot = specialArgs._boot or {}; _boot = specialArgs._boot or { };
_services = specialArgs._services or {}; _services = specialArgs._services or { };
includeHardware = specialArgs.includeHardware or true; includeHardware = specialArgs.includeHardware or true;
proj_root = builtins.toString ./../..; proj_root = builtins.toString ./../..;
in in
with lib; { with lib;
imports = {
( imports = (if includeHardware then [
if includeHardware "${proj_root}/hosts/${hostname}/hardware-configuration.nix"
then [ ] else [ ]) ++ [
"${proj_root}/hosts/${hostname}/hardware-configuration.nix" "${modulesPath}/profiles/minimal.nix"
] "${proj_root}/modules/tailscale.sys.nix"
else [] "${proj_root}/modules/mosh.sys.nix"
) ];
++ [ boot = _boot;
"${modulesPath}/profiles/minimal.nix"
"${proj_root}/modules/tailscale.sys.nix"
"${proj_root}/modules/mosh.sys.nix"
];
boot = _boot;
# prune old builds # prune old builds
nix.settings.auto-optimise-store = true; nix.settings.auto-optimise-store = true;
# Enable nix flakes # Enable nix flakes
nix.package = pkgs.nixFlakes; nix.package = pkgs.nixFlakes;
nix.extraOptions = '' nix.extraOptions = ''
experimental-features = nix-command flakes experimental-features = nix-command flakes
''; '';
users.users.hungtr = { users.users.hungtr = {
isNormalUser = true; isNormalUser = true;
home = "/home/hungtr"; home = "/home/hungtr";
description = "pegasust/hungtr"; description = "pegasust/hungtr";
extraGroups = ["wheel" "networkmanager" "audio"]; extraGroups = [ "wheel" "networkmanager" "audio" ];
}; };
users.users.root = { users.users.root = {
# openssh runs in root, no? This is because port < 1024 requires root. # openssh runs in root, no? This is because port < 1024 requires root.
openssh.authorizedKeys.keys = lib.strings.splitString "\n" (builtins.readFile "${proj_root}/native_configs/ssh/authorized_keys"); openssh.authorizedKeys.keys = lib.strings.splitString "\n" (builtins.readFile "${proj_root}/native_configs/ssh/authorized_keys");
}; };
# Some basic programs # Some basic programs
programs.neovim = { programs.neovim = {
enable = true; enable = true;
defaultEditor = true; defaultEditor = true;
}; };
programs.git = { programs.git = {
enable = true; enable = true;
# more information should be configured under user level # more information should be configured under user level
# See other config at @/home-nix # See other config at @/home-nix
}; };
environment.systemPackages = [
pkgs.gnumake
pkgs.wget
pkgs.inetutils # network diag
pkgs.mtr # network diag
pkgs.sysstat # sys diag
];
}
environment.systemPackages = [
pkgs.gnumake
pkgs.wget
pkgs.inetutils # network diag
pkgs.mtr # network diag
pkgs.sysstat # sys diag
];
}

View File

@ -7,227 +7,208 @@
}; };
}; };
outputs = { outputs = { self, nixpkgs, agenix, ... }:
self, let
nixpkgs, lib = nixpkgs.lib;
agenix, proj_root = ./../..;
... # TODO: Change respectively to the system or make a nix shell to alias `nix run github:ryantm/agenix -- `
}: let base_modules = [
lib = nixpkgs.lib; agenix.nixosModule
proj_root = ./../..; {
# TODO: Change respectively to the system or make a nix shell to alias `nix run github:ryantm/agenix -- ` age.secrets.s3fs = {
base_modules = [ file = ../../secrets/s3fs.age;
agenix.nixosModule # mode = "600"; # owner + group only
{ # owner = "hungtr";
age.secrets.s3fs = { # group = "users";
file = ../../secrets/s3fs.age; };
# mode = "600"; # owner + group only age.secrets."s3fs.digital-garden" = {
# owner = "hungtr"; file = ../../secrets/s3fs.digital-garden.age;
# group = "users"; };
}; age.secrets._nhitrl_cred = {
age.secrets."s3fs.digital-garden" = { file = ../../secrets/_nhitrl.age;
file = ../../secrets/s3fs.digital-garden.age; };
}; environment.systemPackages = [ agenix.defaultPackage.x86_64-linux ];
age.secrets._nhitrl_cred = { }
file = ../../secrets/_nhitrl.age; ];
}; in
environment.systemPackages = [agenix.defaultPackage.x86_64-linux]; {
} # Windows with NixOS WSL
]; nixosConfigurations.Felia = nixpkgs.lib.nixosSystem {
in { system = "x86_64-linux";
# Windows with NixOS WSL modules = base_modules ++ [
nixosConfigurations.Felia = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules =
base_modules
++ [
./wsl-configuration.nix ./wsl-configuration.nix
{ {
system.stateVersion = "22.05"; system.stateVersion = "22.05";
} }
]; ];
specialArgs = { specialArgs = {
# includeHardware = false; # includeHardware = false;
hostname = "Felia"; hostname = "Felia";
_services.openssh = { _services.openssh = {
permitRootLogin = "no"; permitRootLogin = "no";
enable = true; enable = true;
};
}; };
}; };
}; nixosConfigurations.lizzi = nixpkgs.lib.nixosSystem {
nixosConfigurations.lizzi = nixpkgs.lib.nixosSystem { system = "x86_64-linux";
system = "x86_64-linux"; modules = base_modules ++ [
modules =
base_modules
++ [
./configuration.nix ./configuration.nix
{ {
system.stateVersion = "22.05"; system.stateVersion = "22.05";
mod.tailscale.enable = true; mod.tailscale.enable = true;
} }
]; ];
specialArgs = { specialArgs = {
hostname = "lizzi"; hostname = "lizzi";
_networking = { _networking = {
interfaces.eth1.ipv4.addresses = [ interfaces.eth1.ipv4.addresses = [{
{
address = "71.0.0.1"; address = "71.0.0.1";
prefixLength = 24; prefixLength = 24;
} }];
]; firewall = {
firewall = { enable = true;
allowedTCPPorts = [ 80 443 22 ];
};
useDHCP = false;
# required so that we get IP address from linode
interfaces.eth0.useDHCP = true;
};
_boot.loader.grub.enable = true;
_boot.loader.grub.version = 2;
_services.openssh = {
permitRootLogin = "no";
enable = true; enable = true;
allowedTCPPorts = [80 443 22];
}; };
useDHCP = false; _services.gitea = {
# required so that we get IP address from linode enable = true;
interfaces.eth0.useDHCP = true; stateDir = "/gitea";
}; rootUrl = "https://git.pegasust.com";
_boot.loader.grub.enable = true; settings = {
_boot.loader.grub.version = 2; repository = {
_services.openssh = { "ENABLE_PUSH_CREATE_USER" = true;
permitRootLogin = "no"; "ENABLE_PUSH_CREATE_ORG" = true;
enable = true; };
}; };
_services.gitea = { };
enable = true; # Highly suspect that thanks to nginx, ipv6 is disabled?
stateDir = "/gitea"; _services.nginx = {
rootUrl = "https://git.pegasust.com"; enable = true;
settings = { clientMaxBodySize = "100m"; # Allow big file transfers over git :^)
repository = { recommendedGzipSettings = true;
"ENABLE_PUSH_CREATE_USER" = true; recommendedOptimisation = true;
"ENABLE_PUSH_CREATE_ORG" = true; recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts."git.pegasust.com" = {
# Gitea hostname
sslCertificate = "/var/lib/acme/git.pegasust.com/fullchain.pem";
sslCertificateKey = "/var/lib/acme/git.pegasust.com/key.pem";
forceSSL = true; # Runs on port 80 and 443
locations."/".proxyPass = "http://localhost:3000/"; # Proxy to Gitea
}; };
}; };
}; };
# Highly suspect that thanks to nginx, ipv6 is disabled?
_services.nginx = {
enable = true;
clientMaxBodySize = "100m"; # Allow big file transfers over git :^)
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts."git.pegasust.com" = {
# Gitea hostname
sslCertificate = "/var/lib/acme/git.pegasust.com/fullchain.pem";
sslCertificateKey = "/var/lib/acme/git.pegasust.com/key.pem";
forceSSL = true; # Runs on port 80 and 443
locations."/".proxyPass = "http://localhost:3000/"; # Proxy to Gitea
};
};
}; };
}; # Generic machine
# Generic machine nixosConfigurations.pixi = nixpkgs.lib.nixosSystem {
nixosConfigurations.pixi = nixpkgs.lib.nixosSystem { system = "x86_64-linux";
system = "x86_64-linux"; modules = base_modules ++ [
modules =
base_modules
++ [
./configuration.nix ./configuration.nix
{ {
system.stateVersion = "22.05"; system.stateVersion = "22.05";
} }
]; ];
specialArgs = { specialArgs = {
hostname = "pixi"; hostname = "pixi";
_networking = { _networking = {
# interfaces.eth1.ipv4.addresses = [{ # interfaces.eth1.ipv4.addresses = [{
# address = "71.0.0.1"; # address = "71.0.0.1";
# prefixLength = 24; # prefixLength = 24;
# }]; # }];
firewall = { firewall = {
enable = false; enable = false;
allowedTCPPorts = [80 443 22]; allowedTCPPorts = [ 80 443 22 ];
};
useDHCP = false;
# interfaces.eth0.useDHCP = true;
}; };
useDHCP = false; _boot.loader.grub.enable = true;
# interfaces.eth0.useDHCP = true; _boot.loader.grub.version = 2;
}; _services.openssh = {
_boot.loader.grub.enable = true; permitRootLogin = "no";
_boot.loader.grub.version = 2; enable = true;
_services.openssh = { };
permitRootLogin = "no"; _services.gitea = {
enable = true; enable = true;
}; stateDir = "/gitea";
_services.gitea = { rootUrl = "https://git.pegasust.com";
enable = true; settings = {
stateDir = "/gitea"; repository = {
rootUrl = "https://git.pegasust.com"; "ENABLE_PUSH_CREATE_USER" = true;
settings = { "ENABLE_PUSH_CREATE_ORG" = true;
repository = { };
"ENABLE_PUSH_CREATE_USER" = true; };
"ENABLE_PUSH_CREATE_ORG" = true; };
_services.nginx = {
enable = true;
clientMaxBodySize = "100m"; # Allow big file transfers over git :^)
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts."git.pegasust.com" = {
# Gitea hostname
sslCertificate = "/var/lib/acme/git.pegasust.com/fullchain.pem";
sslCertificateKey = "/var/lib/acme/git.pegasust.com/key.pem";
forceSSL = true; # Runs on port 80 and 443
locations."/".proxyPass = "http://localhost:3000/"; # Proxy to Gitea
}; };
}; };
}; };
_services.nginx = {
enable = true;
clientMaxBodySize = "100m"; # Allow big file transfers over git :^)
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts."git.pegasust.com" = {
# Gitea hostname
sslCertificate = "/var/lib/acme/git.pegasust.com/fullchain.pem";
sslCertificateKey = "/var/lib/acme/git.pegasust.com/key.pem";
forceSSL = true; # Runs on port 80 and 443
locations."/".proxyPass = "http://localhost:3000/"; # Proxy to Gitea
};
};
}; };
}; nixosConfigurations.nyx = nixpkgs.lib.nixosSystem {
nixosConfigurations.nyx = nixpkgs.lib.nixosSystem { system = "x86_64-linux";
system = "x86_64-linux"; modules = base_modules ++ [
modules =
base_modules
++ [
./configuration.nix ./configuration.nix
{ {
system.stateVersion = "22.05"; system.stateVersion = "22.05";
} }
]; ];
specialArgs = { specialArgs = {
hostname = "nyx"; hostname = "nyx";
_networking = { _networking = {
enableIPv6 = false; enableIPv6 = false;
interfaces.eth1.ipv4.addresses = [ interfaces.eth1.ipv4.addresses = [{
{
address = "71.0.0.2"; address = "71.0.0.2";
prefixLength = 24; prefixLength = 24;
} }];
]; firewall.enable = true;
firewall.enable = true; useDHCP = false;
useDHCP = false; interfaces.eth0.useDHCP = true;
interfaces.eth0.useDHCP = true; };
}; _boot.loader.grub.enable = true;
_boot.loader.grub.enable = true; _boot.loader.grub.version = 2;
_boot.loader.grub.version = 2; _services.openssh = {
_services.openssh = { permitRootLogin = "no";
permitRootLogin = "no"; enable = true;
enable = true; };
}; };
}; };
}; nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { system = "x86_64-linux";
system = "x86_64-linux"; modules = base_modules ++ [
modules =
base_modules
++ [
./configuration.nix ./configuration.nix
{ {
system.stateVersion = "22.05"; system.stateVersion = "22.05";
} }
]; ];
specialArgs = { specialArgs = {
hostname = "nixos"; hostname = "nixos";
};
}; };
}; nixosConfigurations.htran-dev = nixpkgs.lib.nixosSystem {
nixosConfigurations.htran-dev = nixpkgs.lib.nixosSystem { system = "x86_64-linux";
system = "x86_64-linux"; modules = base_modules ++ [
modules =
base_modules
++ [
./configuration.nix ./configuration.nix
{ {
system.stateVersion = "22.11"; system.stateVersion = "22.11";
@ -237,34 +218,29 @@
# interface = "ens32"; # interface = "ens32";
}; };
networking.interfaces.ens32.ipv4.addresses = [ networking.interfaces.ens32.ipv4.addresses = [
{ { address = "10.100.200.230"; prefixLength = 24; }
address = "10.100.200.230";
prefixLength = 24;
}
]; ];
} }
]; ];
specialArgs = { specialArgs = {
hostname = "htran-dev"; hostname = "htran-dev";
_networking = { _networking = {
firewall.enable = true; firewall.enable = true;
useDHCP = false; useDHCP = false;
interfaces.eth0.useDHCP = true; interfaces.eth0.useDHCP = true;
}; };
_boot.loader.grub.enable = true; _boot.loader.grub.enable = true;
_boot.loader.grub.version = 2; _boot.loader.grub.version = 2;
_services.openssh = { _services.openssh = {
permitRootLogin = "no"; permitRootLogin = "no";
enable = true; enable = true;
};
}; };
}; };
}; nixosConfigurations.bao = nixpkgs.lib.nixosSystem {
nixosConfigurations.bao = nixpkgs.lib.nixosSystem { system = "x86_64-linux";
system = "x86_64-linux"; specialArgs.hostname = "bao";
specialArgs.hostname = "bao"; modules = base_modules ++ [
modules =
base_modules
++ [
./configuration.nix ./configuration.nix
./../../modules/storage.perso.sys.nix ./../../modules/storage.perso.sys.nix
./../../modules/kde.sys.nix ./../../modules/kde.sys.nix
@ -272,63 +248,59 @@
./../../modules/pulseaudio.sys.nix ./../../modules/pulseaudio.sys.nix
./../../modules/opengl.sys.nix ./../../modules/opengl.sys.nix
./../../modules/nvgpu.sys.nix ./../../modules/nvgpu.sys.nix
({ ({ config, pkgs, lib, ... }:
config, {
pkgs, mod.tailscale.enable = true;
lib, # Use UEFI
... boot.loader.systemd-boot.enable = true;
}: {
mod.tailscale.enable = true;
# Use UEFI
boot.loader.systemd-boot.enable = true;
networking.hostName = "bao"; # Define your hostname. networking.hostName = "bao"; # Define your hostname.
# Pick only one of the below networking options. # Pick only one of the below networking options.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
time.timeZone = "America/Phoenix"; time.timeZone = "America/Phoenix";
# Configure keymap in X11 # Configure keymap in X11
services.xserver.layout = "us"; services.xserver.layout = "us";
# services.xserver.xkbOptions = { # services.xserver.xkbOptions = {
# "eurosign:e"; # "eurosign:e";
# "caps:escape" # map caps to escape. # "caps:escape" # map caps to escape.
# }; # };
# Enable CUPS to print documents. # Enable CUPS to print documents.
# services.printing.enable = true; # services.printing.enable = true;
# Enable touchpad support (enabled default in most desktopManager). # Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true; # services.xserver.libinput.enable = true;
# Just an initial user to get this started lol # Just an initial user to get this started lol
users.users.user = { users.users.user = {
initialPassword = "pw123"; initialPassword = "pw123";
extraGroups = ["wheel" "networkmanager" "audio"]; extraGroups = [ "wheel" "networkmanager" "audio" ];
isNormalUser = true; isNormalUser = true;
}; };
# Some programs need SUID wrappers, can be configured further or are # Some programs need SUID wrappers, can be configured further or are
# started in user sessions. # started in user sessions.
# programs.mtr.enable = true; # programs.mtr.enable = true;
# programs.gnupg.agent = { # programs.gnupg.agent = {
# enable = true; # enable = true;
# enableSSHSupport = true; # enableSSHSupport = true;
# }; # };
# List services that you want to enable: # List services that you want to enable:
# Enable the OpenSSH daemon. # Enable the OpenSSH daemon.
services.openssh.enable = true; services.openssh.enable = true;
# This value determines the NixOS release from which the default # This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions # settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave # on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system. # this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option # Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.11"; # Did you read the comment? system.stateVersion = "22.11"; # Did you read the comment?
}) })
]; ];
};
}; };
};
} }

View File

@ -1,20 +1,17 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ { config, lib, pkgs, modulesPath, ... }:
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; {
boot.initrd.kernelModules = []; imports =
boot.kernelParams = ["console=ttyS0,19200n8"]; [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -23,15 +20,17 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
boot.kernelModules = []; boot.kernelModules = [ ];
boot.extraModulePackages = []; boot.extraModulePackages = [ ];
fileSystems."/" = { fileSystems."/" =
device = "/dev/sda"; {
fsType = "ext4"; device = "/dev/sda";
}; fsType = "ext4";
};
swapDevices = [{device = "/dev/sdb";}]; swapDevices =
[{ device = "/dev/sdb"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -3,12 +3,11 @@
let let
lock = builtins.fromJSON (builtins.readFile ./flake.lock); lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in in
fetchTarball { fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; sha256 = lock.nodes.flake-compat.locked.narHash;
} }
) )
{ {
src = ./.; src = ./.;
}) }).defaultNix
.defaultNix

View File

@ -11,13 +11,9 @@
}; };
}; };
outputs = { outputs = { self, nixpkgs, flake-utils, ... }:
self,
nixpkgs,
flake-utils,
...
}:
{ {
nixosModules.wsl = { nixosModules.wsl = {
imports = [ imports = [
./modules/build-tarball.nix ./modules/build-tarball.nix
@ -35,25 +31,26 @@
./configuration.nix ./configuration.nix
]; ];
}; };
}
// flake-utils.lib.eachSystem } //
(with flake-utils.lib.system; ["x86_64-linux" "aarch64-linux"]) flake-utils.lib.eachSystem
( (with flake-utils.lib.system; [ "x86_64-linux" "aarch64-linux" ])
system: let (system:
pkgs = import nixpkgs {inherit system;}; let
in { pkgs = import nixpkgs { inherit system; };
checks.check-format = in
pkgs.runCommand "check-format" {
{ checks.check-format = pkgs.runCommand "check-format"
buildInputs = with pkgs; [nixpkgs-fmt]; {
} '' buildInputs = with pkgs; [ nixpkgs-fmt ];
} ''
nixpkgs-fmt --check ${./.} nixpkgs-fmt --check ${./.}
mkdir $out # success mkdir $out # success
''; '';
devShell = pkgs.mkShell { devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [nixpkgs-fmt]; nativeBuildInputs = with pkgs; [ nixpkgs-fmt ];
}; };
} }
); );
} }

View File

@ -1,24 +1,12 @@
{ { config, pkgs, lib, ... }:
config, with builtins; with lib;
pkgs, let
lib, pkgs2storeContents = l: map (x: { object = x; symlink = "none"; }) l;
...
}:
with builtins;
with lib; let
pkgs2storeContents = l:
map
(x: {
object = x;
symlink = "none";
})
l;
nixpkgs = lib.cleanSource pkgs.path; nixpkgs = lib.cleanSource pkgs.path;
channelSources = channelSources = pkgs.runCommand "nixos-${config.system.nixos.version}"
pkgs.runCommand "nixos-${config.system.nixos.version}" { preferLocalBuild = true; }
{preferLocalBuild = true;}
'' ''
mkdir -p $out mkdir -p $out
cp -prd ${nixpkgs.outPath} $out/nixos cp -prd ${nixpkgs.outPath} $out/nixos
@ -70,7 +58,10 @@ with lib; let
sed -i 's|import \./default\.nix|import \./nixos-wsl|' ./etc/nixos/configuration.nix sed -i 's|import \./default\.nix|import \./nixos-wsl|' ./etc/nixos/configuration.nix
''} ''}
''; '';
in {
in
{
options.wsl.tarball = { options.wsl.tarball = {
includeConfig = mkOption { includeConfig = mkOption {
type = types.bool; type = types.bool;
@ -79,12 +70,13 @@ in {
}; };
}; };
config = mkIf config.wsl.enable { config = mkIf config.wsl.enable {
# These options make no sense without the wsl-distro module anyway # These options make no sense without the wsl-distro module anyway
system.build.tarball = pkgs.callPackage "${nixpkgs}/nixos/lib/make-system-tarball.nix" { system.build.tarball = pkgs.callPackage "${nixpkgs}/nixos/lib/make-system-tarball.nix" {
# No contents, structure will be added by prepare script # No contents, structure will be added by prepare script
contents = []; contents = [ ];
fileName = "nixos-wsl-${pkgs.hostPlatform.system}"; fileName = "nixos-wsl-${pkgs.hostPlatform.system}";
@ -100,5 +92,6 @@ in {
compressCommand = "gzip"; compressCommand = "gzip";
compressionExtension = ".gz"; compressionExtension = ".gz";
}; };
}; };
} }

View File

@ -1,23 +1,20 @@
{ { config, lib, pkgs, ... }:
config, with builtins; with lib; {
lib,
pkgs,
...
}:
with builtins;
with lib; {
imports = [ imports = [
(mkRenamedOptionModule ["wsl" "docker"] ["wsl" "docker-desktop"]) (mkRenamedOptionModule [ "wsl" "docker" ] [ "wsl" "docker-desktop" ])
]; ];
options.wsl.docker-desktop = with types; { options.wsl.docker-desktop = with types; {
enable = mkEnableOption "Docker Desktop integration"; enable = mkEnableOption "Docker Desktop integration";
}; };
config = let config =
cfg = config.wsl.docker-desktop; let
in cfg = config.wsl.docker-desktop;
in
mkIf (config.wsl.enable && cfg.enable) { mkIf (config.wsl.enable && cfg.enable) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
docker docker
docker-compose docker-compose
@ -28,7 +25,7 @@ with lib; {
script = '' script = ''
${config.wsl.automountPath}/wsl/docker-desktop/docker-desktop-user-distro proxy --docker-desktop-root ${config.wsl.automountPath}/wsl/docker-desktop ${config.wsl.automountPath}/wsl/docker-desktop/docker-desktop-user-distro proxy --docker-desktop-root ${config.wsl.automountPath}/wsl/docker-desktop
''; '';
wantedBy = ["multi-user.target"]; wantedBy = [ "multi-user.target" ];
serviceConfig = { serviceConfig = {
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "30s"; RestartSec = "30s";
@ -38,5 +35,7 @@ with lib; {
users.groups.docker.members = [ users.groups.docker.members = [
config.wsl.defaultUser config.wsl.defaultUser
]; ];
}; };
} }

View File

@ -1,11 +1,6 @@
{ { config, lib, pkgs, ... }:
config, with builtins; with lib; {
lib,
pkgs,
...
}:
with builtins;
with lib; {
options.wsl.docker-native = with types; { options.wsl.docker-native = with types; {
enable = mkEnableOption "Native Docker integration in NixOS."; enable = mkEnableOption "Native Docker integration in NixOS.";
@ -20,13 +15,14 @@ with lib; {
}; };
}; };
config = let config =
cfg = config.wsl.docker-native; let
in cfg = config.wsl.docker-native;
in
mkIf (config.wsl.enable && cfg.enable) { mkIf (config.wsl.enable && cfg.enable) {
nixpkgs.overlays = [ nixpkgs.overlays = [
(self: super: { (self: super: {
docker = super.docker.override {iptables = pkgs.iptables-legacy;}; docker = super.docker.override { iptables = pkgs.iptables-legacy; };
}) })
]; ];

View File

@ -1,19 +1,11 @@
{ { config, lib, pkgs, ... }:
config, with builtins; with lib; {
lib,
pkgs,
...
}:
with builtins;
with lib; {
config = mkIf config.wsl.enable ( config = mkIf config.wsl.enable (
let let
mkTarball = pkgs.callPackage "${lib.cleanSource pkgs.path}/nixos/lib/make-system-tarball.nix"; mkTarball = pkgs.callPackage "${lib.cleanSource pkgs.path}/nixos/lib/make-system-tarball.nix";
pkgs2storeContents = map (x: { pkgs2storeContents = map (x: { object = x; symlink = "none"; });
object = x;
symlink = "none";
});
rootfs = let tarball = config.system.build.tarball; in "${tarball}/tarball/${tarball.fileName}.tar${tarball.extension}"; rootfs = let tarball = config.system.build.tarball; in "${tarball}/tarball/${tarball.fileName}.tar${tarball.extension}";
@ -47,39 +39,25 @@ with lib; {
passwd = pkgs.writeText "passwd" '' passwd = pkgs.writeText "passwd" ''
root:x:0:0:System administrator:/root:${installer} root:x:0:0:System administrator:/root:${installer}
''; '';
in { in
{
system.build.installer = mkTarball { system.build.installer = mkTarball {
fileName = "nixos-wsl-installer"; fileName = "nixos-wsl-installer";
compressCommand = "gzip"; compressCommand = "gzip";
compressionExtension = ".gz"; compressionExtension = ".gz";
extraArgs = "--hard-dereference"; extraArgs = "--hard-dereference";
storeContents = with pkgs; storeContents = with pkgs; pkgs2storeContents [
pkgs2storeContents [ installer
installer ];
];
contents = [ contents = [
{ { source = config.environment.etc."wsl.conf".source; target = "/etc/wsl.conf"; }
source = config.environment.etc."wsl.conf".source; { source = config.environment.etc."fstab".source; target = "/etc/fstab"; }
target = "/etc/wsl.conf"; { source = passwd; target = "/etc/passwd"; }
} { source = "${pkgs.busybox}/bin/busybox"; target = "/bin/sh"; }
{ { source = "${pkgs.busybox}/bin/busybox"; target = "/bin/mount"; }
source = config.environment.etc."fstab".source;
target = "/etc/fstab";
}
{
source = passwd;
target = "/etc/passwd";
}
{
source = "${pkgs.busybox}/bin/busybox";
target = "/bin/sh";
}
{
source = "${pkgs.busybox}/bin/busybox";
target = "/bin/mount";
}
]; ];
extraCommands = pkgs.writeShellScript "prepare" '' extraCommands = pkgs.writeShellScript "prepare" ''
@ -88,6 +66,8 @@ with lib; {
ln -s /init bin/wslpath ln -s /init bin/wslpath
''; '';
}; };
} }
); );
} }

View File

@ -1,13 +1,9 @@
{ lib, pkgs, config, ... }:
with builtins; with lib;
{ {
lib,
pkgs,
config,
...
}:
with builtins;
with lib; {
imports = [ imports = [
(mkRenamedOptionModule ["wsl" "compatibility" "interopPreserveArgvZero"] ["wsl" "interop" "preserveArgvZero"]) (mkRenamedOptionModule [ "wsl" "compatibility" "interopPreserveArgvZero" ] [ "wsl" "interop" "preserveArgvZero" ])
]; ];
options.wsl.interop = with types; { options.wsl.interop = with types; {
@ -36,56 +32,57 @@ with lib; {
}; };
}; };
config = let config =
cfg = config.wsl.interop; let
in cfg = config.wsl.interop;
in
mkIf config.wsl.enable { mkIf config.wsl.enable {
boot.binfmt.registrations = mkIf cfg.register { boot.binfmt.registrations = mkIf cfg.register {
WSLInterop = let WSLInterop =
compat = cfg.preserveArgvZero; let
compat = cfg.preserveArgvZero;
# WSL Preview 0.58 and up registers the /init binfmt interp for Windows executable # WSL Preview 0.58 and up registers the /init binfmt interp for Windows executable
# with the "preserve argv[0]" flag, so if you run `./foo.exe`, the interp gets invoked # with the "preserve argv[0]" flag, so if you run `./foo.exe`, the interp gets invoked
# as `/init foo.exe ./foo.exe`. # as `/init foo.exe ./foo.exe`.
# argv[0] --^ ^-- actual path # argv[0] --^ ^-- actual path
# #
# Older versions expect to be called without the argv[0] bit, simply as `/init ./foo.exe`. # Older versions expect to be called without the argv[0] bit, simply as `/init ./foo.exe`.
# #
# We detect that by running `/init /known-not-existing-path.exe` and checking the exit code: # We detect that by running `/init /known-not-existing-path.exe` and checking the exit code:
# the new style interp expects at least two arguments, so exits with exit code 1, # the new style interp expects at least two arguments, so exits with exit code 1,
# presumably meaning "parsing error"; the old style interp attempts to actually run # presumably meaning "parsing error"; the old style interp attempts to actually run
# the executable, fails to find it, and exits with 255. # the executable, fails to find it, and exits with 255.
compatWrapper = pkgs.writeShellScript "nixos-wsl-binfmt-hack" '' compatWrapper = pkgs.writeShellScript "nixos-wsl-binfmt-hack" ''
/init /nixos-wsl-does-not-exist.exe /init /nixos-wsl-does-not-exist.exe
[ $? -eq 255 ] && shift [ $? -eq 255 ] && shift
exec /init "$@" exec /init "$@"
''; '';
# use the autodetect hack if unset, otherwise call /init directly # use the autodetect hack if unset, otherwise call /init directly
interpreter = interpreter = if compat == null then compatWrapper else "/init";
if compat == null
then compatWrapper
else "/init";
# enable for the wrapper and autodetect hack # enable for the wrapper and autodetect hack
preserveArgvZero = preserveArgvZero = if compat == false then false else true;
if compat == false in
then false {
else true; magicOrExtension = "MZ";
in { fixBinary = true;
magicOrExtension = "MZ"; wrapInterpreterInShell = false;
fixBinary = true; inherit interpreter preserveArgvZero;
wrapInterpreterInShell = false; };
inherit interpreter preserveArgvZero;
};
}; };
# Include Windows %PATH% in Linux $PATH. # Include Windows %PATH% in Linux $PATH.
environment.extraInit = mkIf cfg.includePath ''PATH="$PATH:$WSLPATH"''; environment.extraInit = mkIf cfg.includePath ''PATH="$PATH:$WSLPATH"'';
warnings = let warnings =
registrations = config.boot.binfmt.registrations; let
in registrations = config.boot.binfmt.registrations;
in
optional (!(registrations ? WSLInterop) && (length (attrNames config.boot.binfmt.registrations)) != 0) "Having any binfmt registrations without re-registering WSLInterop (wsl.interop.register) will break running .exe files from WSL2"; optional (!(registrations ? WSLInterop) && (length (attrNames config.boot.binfmt.registrations)) != 0) "Having any binfmt registrations without re-registering WSLInterop (wsl.interop.register) will break running .exe files from WSL2";
}; };
} }

View File

@ -1,46 +1,42 @@
{ { lib, pkgs, config, ... }:
lib,
pkgs,
config,
...
}:
with builtins;
with lib; {
options.wsl = with types; let
coercedToStr = coercedTo (oneOf [bool path int]) toString str;
in {
enable = mkEnableOption "support for running NixOS as a WSL distribution";
automountPath = mkOption {
type = str;
default = "/mnt";
description = "The path where windows drives are mounted (e.g. /mnt/c)";
};
automountOptions = mkOption {
type = str;
default = "metadata,uid=1000,gid=100";
description = "Options to use when mounting windows drives";
};
defaultUser = mkOption {
type = str;
default = "nixos";
description = "The name of the default user";
};
startMenuLaunchers = mkEnableOption "shortcuts for GUI applications in the windows start menu";
wslConf = mkOption {
type = attrsOf (attrsOf (oneOf [string int bool]));
description = "Entries that are added to /etc/wsl.conf";
};
};
config = let with builtins; with lib;
cfg = config.wsl; {
syschdemd = import ../syschdemd.nix { options.wsl = with types;
inherit lib pkgs config; let
inherit (cfg) automountPath defaultUser; coercedToStr = coercedTo (oneOf [ bool path int ]) (toString) str;
defaultUserHome = config.users.users.${cfg.defaultUser}.home; in
{
enable = mkEnableOption "support for running NixOS as a WSL distribution";
automountPath = mkOption {
type = str;
default = "/mnt";
description = "The path where windows drives are mounted (e.g. /mnt/c)";
};
automountOptions = mkOption {
type = str;
default = "metadata,uid=1000,gid=100";
description = "Options to use when mounting windows drives";
};
defaultUser = mkOption {
type = str;
default = "nixos";
description = "The name of the default user";
};
startMenuLaunchers = mkEnableOption "shortcuts for GUI applications in the windows start menu";
wslConf = mkOption {
type = attrsOf (attrsOf (oneOf [ string int bool ]));
description = "Entries that are added to /etc/wsl.conf";
};
}; };
in
config =
let
cfg = config.wsl;
syschdemd = import ../syschdemd.nix { inherit lib pkgs config; inherit (cfg) automountPath defaultUser; defaultUserHome = config.users.users.${cfg.defaultUser}.home; };
in
mkIf cfg.enable { mkIf cfg.enable {
wsl.wslConf = { wsl.wslConf = {
automount = { automount = {
enabled = true; enabled = true;
@ -61,8 +57,9 @@ with lib; {
hardware.opengl.enable = true; # Enable GPU acceleration hardware.opengl.enable = true; # Enable GPU acceleration
environment = { environment = {
etc = { etc = {
"wsl.conf".text = generators.toINI {} cfg.wslConf; "wsl.conf".text = generators.toINI { } cfg.wslConf;
# DNS settings are managed by WSL # DNS settings are managed by WSL
hosts.enable = !config.wsl.wslConf.network.generateHosts; hosts.enable = !config.wsl.wslConf.network.generateHosts;
@ -70,7 +67,7 @@ with lib; {
}; };
systemPackages = [ systemPackages = [
(pkgs.runCommand "wslpath" {} '' (pkgs.runCommand "wslpath" { } ''
mkdir -p $out/bin mkdir -p $out/bin
ln -s /init $out/bin/wslpath ln -s /init $out/bin/wslpath
'') '')
@ -82,13 +79,13 @@ with lib; {
users.users.${cfg.defaultUser} = { users.users.${cfg.defaultUser} = {
isNormalUser = true; isNormalUser = true;
uid = 1000; uid = 1000;
extraGroups = ["wheel"]; # Allow the default user to use sudo extraGroups = [ "wheel" ]; # Allow the default user to use sudo
}; };
users.users.root = { users.users.root = {
shell = "${syschdemd}/bin/syschdemd"; shell = "${syschdemd}/bin/syschdemd";
# Otherwise WSL fails to login as root with "initgroups failed 5" # Otherwise WSL fails to login as root with "initgroups failed 5"
extraGroups = ["root"]; extraGroups = [ "root" ];
}; };
security.sudo = { security.sudo = {
@ -100,7 +97,7 @@ with lib; {
system.activationScripts = { system.activationScripts = {
copy-launchers = mkIf cfg.startMenuLaunchers ( copy-launchers = mkIf cfg.startMenuLaunchers (
stringAfter [] '' stringAfter [ ] ''
for x in applications icons; do for x in applications icons; do
echo "Copying /usr/share/$x" echo "Copying /usr/share/$x"
mkdir -p /usr/share/$x mkdir -p /usr/share/$x
@ -108,7 +105,7 @@ with lib; {
done done
'' ''
); );
populateBin = stringAfter [] '' populateBin = stringAfter [ ] ''
echo "setting up /bin..." echo "setting up /bin..."
ln -sf /init /bin/wslpath ln -sf /init /bin/wslpath
ln -sf ${pkgs.bashInteractive}/bin/bash /bin/sh ln -sf ${pkgs.bashInteractive}/bin/bash /bin/sh
@ -137,6 +134,6 @@ with lib; {
enableEmergencyMode = false; enableEmergencyMode = false;
}; };
warnings = optional (config.systemd.services.systemd-resolved.enable && config.wsl.wslConf.network.generateResolvConf) "systemd-resolved is enabled, but resolv.conf is managed by WSL"; warnings = (optional (config.systemd.services.systemd-resolved.enable && config.wsl.wslConf.network.generateResolvConf) "systemd-resolved is enabled, but resolv.conf is managed by WSL");
}; };
} }

View File

@ -1,19 +1,19 @@
{ { lib
lib, , pkgs
pkgs, , config
config, , automountPath
automountPath, , defaultUser
defaultUser, , defaultUserHome ? "/home/${defaultUser}"
defaultUserHome ? "/home/${defaultUser}", , ...
...
}: }:
pkgs.substituteAll { pkgs.substituteAll {
name = "syschdemd"; name = "syschdemd";
src = ./syschdemd.sh; src = ./syschdemd.sh;
dir = "bin"; dir = "bin";
isExecutable = true; isExecutable = true;
buildInputs = with pkgs; [daemonize]; buildInputs = with pkgs; [ daemonize ];
inherit defaultUser defaultUserHome; inherit defaultUser defaultUserHome;
inherit (pkgs) daemonize; inherit (pkgs) daemonize;

View File

@ -1,19 +1,15 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ { config, lib, pkgs, modulesPath, ... }:
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [];
boot.initrd.availableKernelModules = []; {
boot.initrd.kernelModules = []; imports = [ ];
boot.kernelModules = [];
boot.extraModulePackages = []; boot.initrd.availableKernelModules = [ ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
## NOTE: These filesystems are mounted by a wrapper script from nix-wsl ## NOTE: These filesystems are mounted by a wrapper script from nix-wsl
@ -47,22 +43,25 @@
# fsType = "drvfs"; # fsType = "drvfs";
# }; # };
fileSystems."/mnt/c" = { fileSystems."/mnt/c" =
device = "C:"; {
fsType = "drvfs"; device = "C:";
}; fsType = "drvfs";
};
fileSystems."/mnt/d" = { fileSystems."/mnt/d" =
device = "D:"; {
fsType = "drvfs"; device = "D:";
}; fsType = "drvfs";
};
fileSystems."/mnt/f" = { fileSystems."/mnt/f" =
device = "F:"; {
fsType = "drvfs"; device = "F:";
}; fsType = "drvfs";
};
swapDevices = []; swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,22 +1,19 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ { config, lib, pkgs, modulesPath, ... }:
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod"]; {
imports =
[
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
# boot.initrd.kernelModules = [ "amdgpu" ]; # boot.initrd.kernelModules = [ "amdgpu" ];
boot.initrd.kernelModules = []; boot.initrd.kernelModules = [ ];
boot.kernelModules = ["kvm-amd" "coretemp"]; boot.kernelModules = [ "kvm-amd" "coretemp" ];
boot.extraModulePackages = []; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" =
# Might be wise to use /dev/nvme0p1 instead # Might be wise to use /dev/nvme0p1 instead
@ -32,7 +29,7 @@
fsType = "vfat"; fsType = "vfat";
}; };
swapDevices = []; swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,20 +1,17 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ { config, lib, pkgs, modulesPath, ... }:
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; {
boot.initrd.kernelModules = []; imports =
boot.kernelParams = ["console=ttyS0,19200n8"]; [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -23,15 +20,17 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
boot.kernelModules = []; boot.kernelModules = [ ];
boot.extraModulePackages = []; boot.extraModulePackages = [ ];
fileSystems."/" = { fileSystems."/" =
device = "/dev/sda"; {
fsType = "ext4"; device = "/dev/sda";
}; fsType = "ext4";
};
swapDevices = [{device = "/dev/sdb";}]; swapDevices =
[{ device = "/dev/sdb"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,20 +1,17 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ { config, lib, pkgs, modulesPath, ... }:
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; {
boot.initrd.kernelModules = []; imports =
boot.kernelParams = ["console=ttyS0,19200n8"]; [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -23,15 +20,17 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
boot.kernelModules = []; boot.kernelModules = [ ];
boot.extraModulePackages = []; boot.extraModulePackages = [ ];
fileSystems."/" = { fileSystems."/" =
device = "/dev/sda"; {
fsType = "ext4"; device = "/dev/sda";
}; fsType = "ext4";
};
swapDevices = [{device = "/dev/sdb";}]; swapDevices =
[{ device = "/dev/sdb"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,20 +1,17 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ { config, lib, pkgs, modulesPath, ... }:
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; {
boot.initrd.kernelModules = []; imports =
boot.kernelParams = ["console=ttyS0,19200n8"]; [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -23,8 +20,8 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
boot.kernelModules = []; boot.kernelModules = [ ];
boot.extraModulePackages = []; boot.extraModulePackages = [ ];
fileSystems = { fileSystems = {
"/" = { "/" = {
@ -38,7 +35,8 @@
}; };
}; };
swapDevices = [{device = "/dev/sdb";}]; swapDevices =
[{ device = "/dev/sdb"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,23 +1,20 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
config, imports =
lib, [
pkgs, (modulesPath + "/profiles/qemu-guest.nix")
modulesPath, ];
...
}: {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = ["virtio_pci" "virtio_scsi" "ahci" "sd_mod"]; boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
boot.initrd.kernelModules = []; boot.initrd.kernelModules = [ ];
boot.kernelModules = []; boot.kernelModules = [ ];
boot.extraModulePackages = []; boot.extraModulePackages = [ ];
boot.kernelParams = ["console=ttyS0,19200n8"]; boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub.extraConfig = '' boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1 serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial; terminal_input serial;
@ -26,12 +23,14 @@
boot.loader.grub.forceInstall = true; boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev"; boot.loader.grub.device = "nodev";
boot.loader.timeout = 10; boot.loader.timeout = 10;
fileSystems."/" = { fileSystems."/" =
device = "/dev/sda"; {
fsType = "ext4"; device = "/dev/sda";
}; fsType = "ext4";
};
swapDevices = [{device = "/dev/sdb";}]; swapDevices =
[{ device = "/dev/sdb"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@ -1,7 +1,10 @@
{lib, ...}: { lib, ... }:
with lib; let
with lib;
let
nixos-wsl = import ./nixos-wsl; nixos-wsl = import ./nixos-wsl;
in { in
{
imports = [ imports = [
./configuration.nix ./configuration.nix
nixos-wsl.nixosModules.wsl nixos-wsl.nixosModules.wsl
@ -18,7 +21,9 @@ in {
# Enable integration with Docker Desktop (needs to be installed) # Enable integration with Docker Desktop (needs to be installed)
docker-desktop.enable = true; docker-desktop.enable = true;
}; };
# users.users.<defaultUser>.uid = 1000; # users.users.<defaultUser>.uid = 1000;
# networking.hostName = "nixos"; # networking.hostName = "nixos";
} }

View File

@ -1,8 +1,6 @@
{ {inputs, cell}: let
inputs,
cell,
}: let
inherit (inputs) std nixpkgs; inherit (inputs) std nixpkgs;
in { in {
default = std.lib.dev.mkShell { default = std.lib.dev.mkShell {
name = "default"; name = "default";

View File

@ -1,5 +0,0 @@
{
inputs,
cell,
}: let
in {}

View File

@ -1,4 +0,0 @@
{
inputs,
cell,
}: {}

View File

@ -1,200 +1,190 @@
# This is an interface for home-profiles and should not contain opinionated # This is an interface for home-profiles and should not contain opinionated
# configurations. It should provide alternative configurations, aggregates # configurations. It should provide alternative configurations, aggregates
# or new configurations # or new configurations
_imports@{ inputs, cell }: _imports@{inputs, cell}: let
let
namespace = "repo"; namespace = "repo";
imports = _imports // { inherit namespace; }; imports = _imports // {inherit namespace;};
in in {
{ git = { config , lib , ... }: let
git = { config, lib, ... }: cfg = config."${namespace}".git;
let baseAliases = {
cfg = config."${namespace}".git; a = "add";
baseAliases = { c = "commit";
a = "add"; ca = "commit --amend";
c = "commit"; cm = "commit -m";
ca = "commit --amend"; lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
cm = "commit -m"; lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit"; sts = "status";
lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all"; co = "checkout";
sts = "status"; b = "branch";
co = "checkout"; };
b = "branch"; default-user = "Pegasust";
default-email = "pegasucksgg@gmail.com";
in {
options."${namespace}".git = {
aliases = lib.mkOption {
type = lib.types.attrs;
default = { };
example = baseAliases;
description = ''
Additional git aliases. This settings comes with base configuration.
Redeclaring the base config will override the values.
''; # TODO: Add baseAliases as string here (builtins.toString doesn't work)
}; };
default-user = "Pegasust"; name = lib.mkOption {
default-email = "pegasucksgg@gmail.com"; type = lib.types.str;
in default = default-user;
{ description = "Git username that appears on commits";
options."${namespace}".git = { example = default-user;
aliases = lib.mkOption {
type = lib.types.attrs;
default = { };
example = baseAliases;
description = ''
Additional git aliases. This settings comes with base configuration.
Redeclaring the base config will override the values.
''; # TODO: Add baseAliases as string here (builtins.toString doesn't work)
};
name = lib.mkOption {
type = lib.types.str;
default = default-user;
description = "Git username that appears on commits";
example = default-user;
};
email = lib.mkOption {
type = lib.types.str;
default = default-email;
example = default-email;
description = "Git email that appears on commits";
};
ignores = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
".vscode" # vscode settings
".direnv" # .envrc cached outputs
".DS_Store" # MacOS users, amrite
];
description = ''
.gitignore patterns that are applied in every "${namespace}"sitory.
This is useful for IDE-specific settings.
'';
example = [ ".direnv" "node_modules" ];
};
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enables git
'';
example = false;
};
credentialCacheTimeoutSeconds = lib.mkOption {
type = lib.types.int;
default = 3000;
description = "Credential cache (in-memory store) for Git in seconds.";
example = 3000;
};
}; };
# TODO : anyway to override configuration? email = lib.mkOption {
# idk wtf I was thinking about. there is no context in this question type = lib.types.str;
config.programs.git = { default = default-email;
inherit (cfg) enable ignores; example = default-email;
userName = cfg.name; description = "Git email that appears on commits";
userEmail = cfg.email; };
aliases = baseAliases // cfg.aliases; ignores = lib.mkOption {
extraConfig = { type = lib.types.listOf lib.types.str;
# TODO: in the case of darwin, git always open up the built-in keychain. default = [
# possibly something we can't really control since we don't have access to `nix-darwin` ".vscode" # vscode settings
credential.helper = "cache --timeout=${builtins.toString cfg.credentialCacheTimeoutSeconds}"; ".direnv" # .envrc cached outputs
}; ".DS_Store" # MacOS users, amrite
lfs.enable = true; ];
description = ''
.gitignore patterns that are applied in every "${namespace}"sitory.
This is useful for IDE-specific settings.
'';
example = [ ".direnv" "node_modules" ];
};
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enables git
'';
example = false;
};
credentialCacheTimeoutSeconds = lib.mkOption {
type = lib.types.int;
default = 3000;
description = "Credential cache (in-memory store) for Git in seconds.";
example = 3000;
}; };
}; };
# TODO : anyway to override configuration?
# idk wtf I was thinking about. there is no context in this question
config.programs.git = {
inherit (cfg) enable ignores;
userName = cfg.name;
userEmail = cfg.email;
aliases = baseAliases // cfg.aliases;
extraConfig = {
# TODO: in the case of darwin, git always open up the built-in keychain.
# possibly something we can't really control since we don't have access to `nix-darwin`
credential.helper = "cache --timeout=${builtins.toString cfg.credentialCacheTimeoutSeconds}";
};
lfs.enable = true;
};
};
alacritty = { config, lib }: alacritty = {config, lib}: let
let inherit (inputs.cells.repo.lib) fromYAML;
inherit (inputs.cells.repo.lib) fromYAML; cfg = config."${namespace}".alacritty;
cfg = config."${namespace}".alacritty; in {
in options."${namespace}".alacritty = {
{ font.family = lib.mkOption {
options."${namespace}".alacritty = { type = lib.types.nullOr lib.types.singleLineStr;
font.family = lib.mkOption { default = null;
type = lib.types.nullOr lib.types.singleLineStr; description = ''
default = null; The font family for Alacritty
description = '' '';
The font family for Alacritty example = "DroidSansMono NF";
'';
example = "DroidSansMono NF";
};
font.size = lib.mkOption {
type = lib.types.nullOr lib.types.number;
default = 11.0;
description = ''
The default font size for Alacritty. This is probably measured in px.
'';
example = 7.0;
};
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Enables alacritty
'';
example = true;
};
config-path = lib.mkOption {
type = lib.types.path;
description = "Path to alacritty yaml";
default = null;
example = "./config/alacritty.yaml";
};
}; };
config.programs.alacritty = { font.size = lib.mkOption {
enable = cfg.enable; type = lib.types.nullOr lib.types.number;
settings = default = null;
let description = ''
; The default font size for Alacritty. This is probably measured in px.
actualConfig = '';
if cfg.config-path != null then fromYAML (builtins.readFile cfg.config-path) else { }; example = 7.0;
in };
lib.recursiveUpdate actualConfig { enable = lib.mkOption {
font.normal.family = lib.mkIf (font.family != null) font.family; type = lib.types.bool;
font.size = lib.mkIf (font.size != null) font.size; default = false;
}; description = ''
Enables alacritty
'';
example = true;
};
config-file = lib.mkOption {
type = lib.types.path;
description = "Path to alacritty yaml";
default = null;
example = "./config/alacritty.yaml";
}; };
}; };
config.programs.alacritty = {
enable = cfg.enable;
settings = let ;
actualConfig = if cfg.config-file != null then fromYAML (builtins.readFile cfg.config-file) else {};
in lib.recursiveUpdate actualConfig {
font.normal.family = opt-toNullable(opt-leftmostSome (builtins.map opt-fromNullable [
cfg.font.family actualConfig.font.family actualConfig.font.normal.family
]));
font.size = cfg.font.size or actualConfig.font.size or 7.0;
};
};
};
# TODO: chromium is not really supported on darwin # TODO: chromium is not really supported on darwin
private_chromium = { config, pkgs, lib, ... }: private_chromium = { config, pkgs, lib, ... }: let
let cfg = config."${namespace}".private_chromium;
cfg = config."${namespace}".private_chromium; in {
in options."${namespace}".private_chromium = {
{ enable = lib.mkOption {
options."${namespace}".private_chromium = { type = lib.types.bool;
enable = lib.mkOption { default = true;
type = lib.types.bool; example = false;
default = true; description = ''
example = false; Enable extremely lightweight chromium with vimium plugin
description = '' '';
Enable extremely lightweight chromium with vimium plugin
'';
};
};
config = lib.mkIf (cfg.enable) {
# home.packages = [pkgs.ungoogled-chromium];
programs.chromium = {
enable = true;
package = pkgs.ungoogled-chromium;
extensions =
let
# TODO: how about a chrome extension registry?
mkChromiumExtForVersion = browserVersion: { id, sha256, extVersion, ... }:
{
inherit id;
crxPath = builtins.fetchurl {
url = "https://clients2.google.com/service/update2/crx" +
"?response=redirect" +
"&acceptformat=crx2,crx3" +
"&prodversion=${browserVersion}" +
"&x=id%3D${id}%26installsource%3Dondemand%26uc";
name = "${id}.crx";
inherit sha256;
};
version = extVersion;
};
mkChromiumExt = mkChromiumExtForVersion (lib.versions.major pkgs.ungoogled-chromium.version);
in
[
# vimium
(mkChromiumExt {
id = "dbepggeogbaibhgnhhndojpepiihcmeb";
sha256 = "00qhbs41gx71q026xaflgwzzridfw1sx3i9yah45cyawv8q7ziic";
extVersion = "1.67.4";
})
];
};
}; };
}; };
config = lib.mkIf (cfg.enable) {
# home.packages = [pkgs.ungoogled-chromium];
programs.chromium = {
enable = true;
package = pkgs.ungoogled-chromium;
extensions =
let
# TODO: how about a chrome extension registry?
mkChromiumExtForVersion = browserVersion: { id, sha256, extVersion, ... }:
{
inherit id;
crxPath = builtins.fetchurl {
url = "https://clients2.google.com/service/update2/crx" +
"?response=redirect" +
"&acceptformat=crx2,crx3" +
"&prodversion=${browserVersion}" +
"&x=id%3D${id}%26installsource%3Dondemand%26uc";
name = "${id}.crx";
inherit sha256;
};
version = extVersion;
};
mkChromiumExt = mkChromiumExtForVersion (lib.versions.major pkgs.ungoogled-chromium.version);
in
[
# vimium
(mkChromiumExt {
id = "dbepggeogbaibhgnhhndojpepiihcmeb";
sha256 = "00qhbs41gx71q026xaflgwzzridfw1sx3i9yah45cyawv8q7ziic";
extVersion = "1.67.4";
})
];
};
};
};
darwin-spotlight = { lib, pkgs, config, ... }: { darwin-spotlight = { lib, pkgs, config, ... }: {
# This patch exists since Darwin's search bar requires solid apps and not # This patch exists since Darwin's search bar requires solid apps and not
@ -234,7 +224,7 @@ in
""; "";
# We need this in case upstream home-manager changes the behavior of linking # We need this in case upstream home-manager changes the behavior of linking
# applications # applications
home.activation.remove-patch-spotlight = home.activation.remove-patch-spotlight =
if pkgs.stdenv.isDarwin then if pkgs.stdenv.isDarwin then
lib.hm.dag.entryBefore [ "checkLinkTargets" ] '' lib.hm.dag.entryBefore [ "checkLinkTargets" ] ''
HM_APPS="$HOME/Applications/Home Manager Apps" HM_APPS="$HOME/Applications/Home Manager Apps"
@ -246,6 +236,6 @@ in
else else
""; "";
}; };
} }

View File

@ -1,18 +1,11 @@
{ {inputs, cell, namespace}: { pkgs, config, lib, ... }:
inputs, let
cell,
namespace,
}: {
pkgs,
config,
lib,
...
}: let
cfg = config."${namespace}".graphics; cfg = config."${namespace}".graphics;
cfgEnable = cfg.enable or (cfg.useNixGL.defaultPackage != null); cfgEnable = cfg.enable or (cfg.useNixGL.defaultPackage != null);
types = lib.types; types = lib.types;
in { in
imports = [./shells.nix]; {
imports = [ ./shells.nix ];
options."${namespace}".nixgl = { options."${namespace}".nixgl = {
enable = lib.mkEnableOption "nixgl"; enable = lib.mkEnableOption "nixgl";
useNixGL = { useNixGL = {
@ -24,7 +17,7 @@ in {
]; ];
}; };
defaultPackage = lib.mkOption { defaultPackage = lib.mkOption {
type = types.nullOr (types.enum ["nixGLIntel" "nixGLNvidia" "nixGLNvidiaBumblebee"]); type = types.nullOr (types.enum [ "nixGLIntel" "nixGLNvidia" "nixGLNvidiaBumblebee" ]);
description = "Which nixGL package to be aliased as `nixGL` on the shell"; description = "Which nixGL package to be aliased as `nixGL` on the shell";
default = null; default = null;
example = "nixGLIntel"; example = "nixGLIntel";
@ -42,6 +35,6 @@ in {
nixGL = cfg.useNixGL.defaultPackage; nixGL = cfg.useNixGL.defaultPackage;
}; };
}; };
home.packages = [cfg.useNixGL.package]; home.packages = [ cfg.useNixGL.package ];
}; };
} }

View File

@ -1,15 +1,11 @@
{inputs, cell, namespace}: { config
, lib
, pkgs
, ...
}:
let cfg = config."${namespace}".shells;
in
{ {
inputs,
cell,
namespace,
}: {
config,
lib,
pkgs,
...
}: let
cfg = config."${namespace}".shells;
in {
options."${namespace}".shells = { options."${namespace}".shells = {
enable = lib.mkOption { enable = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
@ -30,7 +26,7 @@ in {
shellAliases = lib.mkOption { shellAliases = lib.mkOption {
type = lib.types.attrs; type = lib.types.attrs;
description = "Shell command aliases"; description = "Shell command aliases";
default = {}; default = { };
example = { example = {
nixGL = "nixGLIntel"; nixGL = "nixGLIntel";
}; };
@ -51,8 +47,9 @@ in {
}; };
programs.tmux = { programs.tmux = {
enable = true; enable = true;
plugins = let inherit (pkgs.tmuxPlugins) cpu net-speed; in [cpu net-speed]; # extraConfigBeforePlugin = builtins.readFile "${proj_root.config.path}/tmux/tmux.conf";
extraConfig = builtins.readFile "${innputs.self}/native_configs/tmux/tmux.conf"; plugins = let inherit (pkgs.tmuxPlugins) cpu net-speed; in [ cpu net-speed ];
extraConfig = (builtins.readFile "${proj_root.config.path}/tmux/tmux.conf");
}; };
xdg.configFile."tmux/tmux.conf".text = lib.mkOrder 600 '' xdg.configFile."tmux/tmux.conf".text = lib.mkOrder 600 ''
set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M ' set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M '
@ -66,16 +63,15 @@ in {
programs.starship = { programs.starship = {
enable = true; enable = true;
enableZshIntegration = true; enableZshIntegration = true;
settings = let settings = let
native = builtins.fromTOML (builtins.readFile "${inputs.self}/native_configs/starship/starship.toml"); native = builtins.fromTOML (builtins.readFile "${proj_root.config.path}/starship/starship.toml");
patch-nix = pkgs.lib.recursiveUpdate native { patch-nix = pkgs.lib.recursiveUpdate native ({
c.commands = [ c.commands = [
["nix" "run" "nixpkgs#clang" "--" "--version"] ["nix" "run" "nixpkgs#clang" "--" "--version"]
["nix" "run" "nixpkgs#gcc" "--" "--version"] ["nix" "run" "nixpkgs#gcc" "--" "--version"]
]; ];
}; });
in in patch-nix;
patch-nix;
}; };
# Fuzzy finder. `fzf` for TUI, `fzf -f '<fuzzy query>'` for UNIX piping # Fuzzy finder. `fzf` for TUI, `fzf -f '<fuzzy query>'` for UNIX piping
programs.fzf.enable = true; programs.fzf.enable = true;
@ -88,12 +84,10 @@ in {
enable = true; enable = true;
enableCompletion = true; enableCompletion = true;
enableAutosuggestions = true; enableAutosuggestions = true;
shellAliases = shellAliases = {
{ nix-rebuild = "sudo nixos-rebuild switch";
nix-rebuild = "sudo nixos-rebuild switch"; hm-switch = "home-manager switch --flake";
hm-switch = "home-manager switch --flake"; } // (cfg.shellAliases or { });
}
// (cfg.shellAliases or {});
history = { history = {
size = 10000; size = 10000;
path = "${config.xdg.dataHome}/zsh/history"; path = "${config.xdg.dataHome}/zsh/history";
@ -118,11 +112,10 @@ in {
ZVM_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :) ZVM_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :)
ZVM_ESCAPE_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :) ZVM_ESCAPE_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :)
}; };
initExtra = initExtra = (cfg.shellInitExtra or "") + ''
(cfg.shellInitExtra or "") source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
+ '' '';
source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
'';
}; };
}; };
} }

View File

@ -1,27 +1,15 @@
# This creates a layer that is specific to some profiles, but may require _imports@{inputs, cell}: let
# some variants in environment like username/email, work-oriented or personal
# and many more
_imports @ {
inputs,
cell,
}: let
# TODO: I don't think abstracting namespace away is a good idea in this case
namespace = "repo"; namespace = "repo";
imports = _imports // {inherit namespace;}; imports = _imports // {inherit namespace;};
in { in {
neovim = import ./neovim.nix imports; neovim = import ./neovim.nix imports;
nerd_font_module = { nerd_font_module = {config, pkgs, ...}: {
config,
pkgs,
...
}: {
imports = [ imports = [
import import inputs.cells."${namespace}"
inputs.cells."${namespace}"
]; ];
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
home.packages = [ home.packages = [
(pkgs.nerdfonts.override {fonts = ["Hack"];}) (pkgs.nerdfonts.override { fonts = [ "Hack" ]; })
]; ];
"${namespace}".alacritty.font.family = "Hack Nerd Font Mono"; "${namespace}".alacritty.font.family = "Hack Nerd Font Mono";
}; };
@ -44,13 +32,7 @@ in {
}; };
}; };
ssh = { ssh = {config, lib, ...}: let cfg = config."${namespace}".ssh; in {
config,
lib,
...
}: let
cfg = config."${namespace}".ssh;
in {
options."${namespace}".ssh.enable = lib.mkOption { options."${namespace}".ssh.enable = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = true; default = true;
@ -66,79 +48,13 @@ in {
}; };
}; };
alacritty = { alacritty = {config, lib,...}: let cfg = config."${namespace}".alacritty; in {
config,
lib,
...
}: let
cfg = config."${namespace}".alacritty;
in {
imports = [ imports = [
import import "${inputs.cells.repo.home-modules.alacritty}"
"${inputs.cells.repo.home-modules.alacritty}"
]; ];
configs."${namespace}".alacritty = { configs."${namespace}".alacritty = {
enable = true; enable = true;
config-path = "${inputs.self}//native-configs/alacritty/alacritty.yml"; config-file = "${inputs.self}//native-configs/alacritty/alacritty.yml";
font.size = 11.0;
font.family = "Hack Nerd Font Mono";
};
};
shells = import ./shells.nix imports;
git = {
config,
pkgs,
lib,
...
}: let
baseAliases = {
a = "add";
c = "commit";
ca = "commit --amend";
cm = "commit -m";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
sts = "status";
co = "checkout";
b = "branch";
};
in {
options."${namespace}".git = {
aliases = lib.mkOption {
type = lib.types.attrs;
default = {};
example = baseAliases;
description = ''
Additional git aliases. This config is merged on top of base aliases.
'';
};
name = lib.mkOption {
type = lib.types.str;
default = "Pegasust";
description = "Git username that appears on commits";
example = "Pegasust";
};
email = lib.mkOption {
type = lib.types.str;
default = "pegasucksgg@gmail.com";
example = "peagsucksgg@gmail.com";
description = "Git email that appears on commits";
};
ignores = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
".vscode" # vscode settings
".direnv" # .envrc cached outputs
".DS_Store" # MacOS users, amrite
];
description = ''
.gitignore patterns that are applied in every repository.
This is useful for IDE-specific or environment-specific settings.
'';
example = [".direnv" "node_modules"];
};
}; };
}; };
} }

View File

@ -2,72 +2,62 @@
# #
# One thing to consider, though, /nix/store of `nix-shell` or `nix-develop` # One thing to consider, though, /nix/store of `nix-shell` or `nix-develop`
# might be different from `home-manager`'s (~/.nix_profile/bin/jq) # might be different from `home-manager`'s (~/.nix_profile/bin/jq)
{ {inputs, cell, namespace}: { pkgs, lib, config, ... }:
inputs, let
cell,
namespace,
}: {
pkgs,
lib,
config,
...
}: let
# NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace # NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace
# and is added to the path after wrapping. # and is added to the path after wrapping.
# check: nix repl `homeConfigurations.hungtr.config.programs.neovim.finalPackage.buildCommand` # check: nix repl `homeConfigurations.hungtr.config.programs.neovim.finalPackage.buildCommand`
# see: :/--suffix.*PATH # see: :/--suffix.*PATH
# there should be mentions of additional packages # there should be mentions of additional packages
my_neovim = pkgs.neovim-unwrapped; my_neovim = pkgs.neovim-unwrapped;
rust_pkgs = rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith
pkgs.rust-bin.selectLatestNightlyWith
( (
toolchain: toolchain:
toolchain.default.override { toolchain.default.override {
extensions = ["rust-src" "rust-analyzer" "rust-docs" "rustfmt" "clippy" "miri"]; extensions = [ "rust-src" "rust-analyzer" "rust-docs" "rustfmt" "clippy" "miri" ];
} }
); ));
nvim_pkgs = nvim_pkgs = [
# pkgs.gccStdenv
pkgs.tree-sitter
pkgs.fzf # file name fuzzy search
pkgs.ripgrep # content fuzzy search
pkgs.zk # Zettelkasten (limited support)
pkgs.fd # Required by a Telescope plugin (?)
pkgs.stdenv.cc.cc.lib
pkgs.rnix-lsp # doesn't work, Mason just installs it using cargo
pkgs.rust4cargo
pkgs.nickel
pkgs.nls
pkgs.go # doesn't work, Mason installs from runtime path
# Language-specific stuffs
pkgs.sumneko-lua-language-server
# pkgs.python3Packages.python-lsp-server
pkgs.nodePackages.pyright
pkgs.python3Packages.pylint
pkgs.python3Packages.flake8
# FIXME: installing ansible from here just doesn't work :/
# pkgs.ansible-lint
# pkgs.python38Packages.ansible
# pkgs.ansible-language-server
# TODO: the devShell should provide rust-analyzer so that
# cargo test builds binaries compatible with rust-analyzer
# pkgs.rust-analyzer
# rust_pkgs
# pkgs.evcxr # Rust REPL for Conjure!
] ++ lib.optionals (pkgs.stdenv.isDarwin) (
let
inherit (pkgs.darwin.apple_sdk.frameworks) System CoreFoundation; in
[ [
# pkgs.gccStdenv System
pkgs.tree-sitter CoreFoundation
pkgs.fzf # file name fuzzy search
pkgs.ripgrep # content fuzzy search
pkgs.zk # Zettelkasten (limited support)
pkgs.fd # Required by a Telescope plugin (?)
pkgs.stdenv.cc.cc.lib
pkgs.rnix-lsp # doesn't work, Mason just installs it using cargo
pkgs.rust4cargo
pkgs.nickel
pkgs.nls
pkgs.go # doesn't work, Mason installs from runtime path
# Language-specific stuffs
pkgs.sumneko-lua-language-server
# pkgs.python3Packages.python-lsp-server
pkgs.nodePackages.pyright
pkgs.python3Packages.pylint
pkgs.python3Packages.flake8
# FIXME: installing ansible from here just doesn't work :/
# pkgs.ansible-lint
# pkgs.python38Packages.ansible
# pkgs.ansible-language-server
# TODO: the devShell should provide rust-analyzer so that
# cargo test builds binaries compatible with rust-analyzer
# pkgs.rust-analyzer
# rust_pkgs
# pkgs.evcxr # Rust REPL for Conjure!
] ]
++ lib.optionals (pkgs.stdenv.isDarwin) ( );
let in
inherit (pkgs.darwin.apple_sdk.frameworks) System CoreFoundation; {
in [
System
CoreFoundation
]
);
in {
options.base.neovim = { options.base.neovim = {
enable = lib.mkOption { enable = lib.mkOption {
default = true; default = true;
@ -87,54 +77,60 @@ in {
withNodeJs = true; withNodeJs = true;
# NOTE: this adds path to the wrapped version of neovim # NOTE: this adds path to the wrapped version of neovim
extraPackages = nvim_pkgs; extraPackages = nvim_pkgs;
extraLuaConfig = builtins.readFile "${inputs.self}/native_configs/neovim/init.lua"; extraLuaConfig = (builtins.readFile "${inputs.self}/native_configs/neovim/init.lua");
plugins = let plugins = (let inherit (pkgs.vimPlugins)
inherit plenary-nvim
(pkgs.vimPlugins)
plenary-nvim nvim-treesitter
nvim-treesitter nvim-treesitter-textobjects
nvim-treesitter-textobjects nvim-treesitter-context
nvim-treesitter-context
telescope-fzf-native-nvim telescope-fzf-native-nvim
telescope-file-browser-nvim telescope-file-browser-nvim
telescope-nvim telescope-nvim
nvim-lspconfig
gruvbox-community nvim-lspconfig
neodev-nvim
cmp-nvim-lsp gruvbox-community
cmp-path
cmp-buffer neodev-nvim
cmp-cmdline
nvim-cmp cmp-nvim-lsp
lspkind-nvim cmp-path
nvim-autopairs cmp-buffer
nvim-ts-autotag cmp-cmdline
guess-indent-nvim nvim-cmp
harpoon
zk-nvim lspkind-nvim
luasnip nvim-autopairs
fidget-nvim nvim-ts-autotag
rust-tools-nvim guess-indent-nvim
cmp_luasnip harpoon
gitsigns-nvim zk-nvim
indent-blankline-nvim luasnip
lualine-nvim fidget-nvim
mason-lspconfig-nvim rust-tools-nvim
mason-nvim
neogit cmp_luasnip
nlua-nvim gitsigns-nvim
nvim-jqx indent-blankline-nvim
nvim-surround lualine-nvim
nvim-web-devicons mason-lspconfig-nvim
playground mason-nvim
todo-comments-nvim neogit
trouble-nvim nlua-nvim
vim-dispatch nvim-jqx
vim-dispatch-neovim nvim-surround
vim-fugitive nvim-web-devicons
vim-jack-in playground
; todo-comments-nvim
in [ trouble-nvim
vim-dispatch
vim-dispatch-neovim
vim-fugitive
vim-jack-in
; in [
plenary-nvim plenary-nvim
nvim-treesitter.withAllGrammars nvim-treesitter.withAllGrammars
nvim-treesitter-textobjects nvim-treesitter-textobjects
@ -177,8 +173,8 @@ in {
vim-dispatch vim-dispatch
vim-dispatch-neovim vim-dispatch-neovim
vim-fugitive vim-fugitive
vim-jack-in vim-jack-in
]; ]);
}; };
# home.packages = nvim_pkgs; # home.packages = nvim_pkgs;
}; };

View File

@ -1,39 +1,35 @@
{ inputs, cell }: {inputs, cell}: let
let
namespace = "repo"; namespace = "repo";
yamlToJsonDrv = pkgs: yamlContent: outputPath: (pkgs.runCommand yamlToJsonDrv = pkgs: yamlContent: outputPath: (pkgs.runCommand
outputPath outputPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; }
{ inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; } # run yq which outputs '.' (no filter) on file at yamlPath
# run yq which outputs '.' (no filter) on file at yamlPath # note that $out is passed onto the bash/sh script for execution
# note that $out is passed onto the bash/sh script for execution ''
'' echo "$yamlContent" | yq >$out
echo "$yamlContent" | yq >$out '')
'')
{ }); { });
in in {
{
fromYAML = yamlContent: bulitins.fromJSON (builtins.readFile (yamlToJsonDrv inputs.nixpkgs yamlContent "fromYaml.json")); fromYAML = yamlContent: bulitins.fromJSON (builtins.readFile (yamlToJsonDrv inputs.nixpkgs yamlContent "fromYaml.json"));
# NOTE: Deprecate
# ctor # ctor
opt-some = a: [ a ]; opt-some = a: [a];
opt-none = [ ]; opt-none = [];
opt-none_thunk = _: [ ]; opt-none_thunk = _: [];
# from-to null # from-to null
opt-fromNullable = nullable: if nullable == null then [ ] else [ nullable ]; opt-fromNullable = nullable: if nullable == null then [] else [nullable];
opt-toNullable = opt-fork (a:a) (_: null); opt-toNullable = opt-fork (a:a) (_: null);
opt-map = builtins.map; opt-map = builtins.map;
opt-filter = builtins.filter; opt-filter = builtins.filter;
opt-fork = on_some: on_none: opt: if opt == [ ] then (on_none null) else (on_some (builtins.elemAt opt 0)); opt-fork = on_some: on_none: opt: if opt == [] then (on_none null) else (on_some (builtins.elemAt opt 0));
opt-unwrap = opt-fork (a:a) (_: throw "opt-unwrap: expected some, got none"); opt-unwrap = opt-fork (a:a) (_: throw "opt-unwrap: expected some, got none");
opt-unwrapOrElse = opt-fork (a:a); opt-unwrapOrElse = opt-fork (a:a);
opt-unwrapOr = fallback_val: opt-fork (a:a) (_: fallback_val); opt-unwrapOr = fallback_val: opt-fork (a:a) (_: fallback_val);
opt-orElse = opt: fallback_opt: opt-fork (opt-some) (opt-none_thunk) (opt ++ fallback_opt); opt-orElse = opt: fallback_opt: opt-fork (opt-some) (opt-none_thunk) (opt ++ fallback_opt);
opt-leftmostSome = opts: builtins.foldl' (opt-orElse) [ ] opts; opt-leftmostSome = opts: builtins.foldl' (opt-orElse) [] opts;
} }

View File

@ -1,7 +1,4 @@
{ {inputs, cell}: {
inputs,
cell,
}: {
htran = inputs.cells.dotfiles.devshells.default; htran = inputs.cells.dotfiles.devshells.default;
hungtran = inputs.cells.dotfiles.devshells.default; hungtran = inputs.cells.dotfiles.devshells.default;
} }

View File

@ -4,265 +4,182 @@
# calls the flake's 'outputs' function. It then returns an attrset # calls the flake's 'outputs' function. It then returns an attrset
# containing 'defaultNix' (to be used in 'default.nix'), 'shellNix' # containing 'defaultNix' (to be used in 'default.nix'), 'shellNix'
# (to be used in 'shell.nix'). # (to be used in 'shell.nix').
{
src, { src, system ? builtins.currentSystem or "unknown-system" }:
system ? builtins.currentSystem or "unknown-system",
}: let let
lockFilePath = src + "/flake.lock"; lockFilePath = src + "/flake.lock";
lockFile = builtins.fromJSON (builtins.readFile lockFilePath); lockFile = builtins.fromJSON (builtins.readFile lockFilePath);
fetchTree = info: fetchTree =
if info.type == "github" info:
then { if info.type == "github" then
outPath = { outPath =
fetchTarball fetchTarball
( ({ url = "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}"; }
{url = "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}";} // (if info ? narHash then { sha256 = info.narHash; } else {})
// ( );
if info ? narHash rev = info.rev;
then {sha256 = info.narHash;} shortRev = builtins.substring 0 7 info.rev;
else {}
)
);
rev = info.rev;
shortRev = builtins.substring 0 7 info.rev;
lastModified = info.lastModified;
lastModifiedDate = formatSecondsSinceEpoch info.lastModified;
narHash = info.narHash;
}
else if info.type == "git"
then
{
outPath =
builtins.fetchGit
(
{url = info.url;}
// (
if info ? rev
then {inherit (info) rev;}
else {}
)
// (
if info ? ref
then {inherit (info) ref;}
else {}
)
// (
if info ? submodules
then {inherit (info) submodules;}
else {}
)
);
lastModified = info.lastModified; lastModified = info.lastModified;
lastModifiedDate = formatSecondsSinceEpoch info.lastModified; lastModifiedDate = formatSecondsSinceEpoch info.lastModified;
narHash = info.narHash; narHash = info.narHash;
} }
// ( else if info.type == "git" then
if info ? rev { outPath =
then { builtins.fetchGit
rev = info.rev; ({ url = info.url; }
shortRev = builtins.substring 0 7 info.rev; // (if info ? rev then { inherit (info) rev; } else {})
} // (if info ? ref then { inherit (info) ref; } else {})
else {} // (if info ? submodules then { inherit (info) submodules; } else {})
) );
else if info.type == "path" lastModified = info.lastModified;
then { lastModifiedDate = formatSecondsSinceEpoch info.lastModified;
outPath = builtins.path { narHash = info.narHash;
path = } // (if info ? rev then {
if builtins.substring 0 1 info.path != "/" rev = info.rev;
then src + ("/" + info.path) # make this absolute path by prepending ./ shortRev = builtins.substring 0 7 info.rev;
} else {
})
else if info.type == "path" then
{ outPath = builtins.path {
path = if builtins.substring 0 1 info.path != "/"
then src + ("/" + info.path) # make this absolute path by prepending ./
else info.path; # it's already an absolute path else info.path; # it's already an absolute path
}; };
narHash = info.narHash; narHash = info.narHash;
} }
else if info.type == "tarball" else if info.type == "tarball" then
then { { outPath =
outPath = fetchTarball
fetchTarball ({ inherit (info) url; }
( // (if info ? narHash then { sha256 = info.narHash; } else {})
{inherit (info) url;} );
// ( }
if info ? narHash else if info.type == "gitlab" then
then {sha256 = info.narHash;} { inherit (info) rev narHash lastModified;
else {} outPath =
) fetchTarball
); ({ url = "https://${info.host or "gitlab.com"}/api/v4/projects/${info.owner}%2F${info.repo}/repository/archive.tar.gz?sha=${info.rev}"; }
} // (if info ? narHash then { sha256 = info.narHash; } else {})
else if info.type == "gitlab" );
then { shortRev = builtins.substring 0 7 info.rev;
inherit (info) rev narHash lastModified; }
outPath =
fetchTarball
(
{url = "https://${info.host or "gitlab.com"}/api/v4/projects/${info.owner}%2F${info.repo}/repository/archive.tar.gz?sha=${info.rev}";}
// (
if info ? narHash
then {sha256 = info.narHash;}
else {}
)
);
shortRev = builtins.substring 0 7 info.rev;
}
else else
# FIXME: add Mercurial, tarball inputs. # FIXME: add Mercurial, tarball inputs.
throw "flake input has unsupported input type '${info.type}'"; throw "flake input has unsupported input type '${info.type}'";
callFlake4 = flakeSrc: locks: let callFlake4 = flakeSrc: locks:
flake = import (flakeSrc + "/flake.nix"); let
flake = import (flakeSrc + "/flake.nix");
inputs = inputs = builtins.mapAttrs (n: v:
builtins.mapAttrs
(n: v:
if v.flake or true if v.flake or true
then callFlake4 (fetchTree (v.locked // v.info)) v.inputs then callFlake4 (fetchTree (v.locked // v.info)) v.inputs
else fetchTree (v.locked // v.info)) else fetchTree (v.locked // v.info)) locks;
locks;
outputs = flakeSrc // (flake.outputs (inputs // {self = outputs;})); outputs = flakeSrc // (flake.outputs (inputs // {self = outputs;}));
in in
assert flake.edition == 201909; outputs; assert flake.edition == 201909;
outputs;
callLocklessFlake = flakeSrc: let callLocklessFlake = flakeSrc:
flake = import (flakeSrc + "/flake.nix"); let
outputs = flakeSrc // (flake.outputs {self = outputs;}); flake = import (flakeSrc + "/flake.nix");
in outputs = flakeSrc // (flake.outputs ({ self = outputs; }));
outputs; in outputs;
rootSrc = let rootSrc = let
# Try to clean the source tree by using fetchGit, if this source # Try to clean the source tree by using fetchGit, if this source
# tree is a valid git repository. # tree is a valid git repository.
tryFetchGit = src: tryFetchGit = src:
if isGit && !isShallow if isGit && !isShallow
then let then
res = builtins.fetchGit src; let res = builtins.fetchGit src;
in in if res.rev == "0000000000000000000000000000000000000000" then removeAttrs res ["rev" "shortRev"] else res
if res.rev == "0000000000000000000000000000000000000000" else { outPath = src; };
then removeAttrs res ["rev" "shortRev"]
else res
else {outPath = src;};
# NB git worktrees have a file for .git, so we don't check the type of .git # NB git worktrees have a file for .git, so we don't check the type of .git
isGit = builtins.pathExists (src + "/.git"); isGit = builtins.pathExists (src + "/.git");
isShallow = builtins.pathExists (src + "/.git/shallow"); isShallow = builtins.pathExists (src + "/.git/shallow");
in in
{ { lastModified = 0; lastModifiedDate = formatSecondsSinceEpoch 0; }
lastModified = 0; // (if src ? outPath then src else tryFetchGit src);
lastModifiedDate = formatSecondsSinceEpoch 0;
}
// (
if src ? outPath
then src
else tryFetchGit src
);
# Format number of seconds in the Unix epoch as %Y%m%d%H%M%S. # Format number of seconds in the Unix epoch as %Y%m%d%H%M%S.
formatSecondsSinceEpoch = t: let formatSecondsSinceEpoch = t:
rem = x: y: x - x / y * y; let
days = t / 86400; rem = x: y: x - x / y * y;
secondsInDay = rem t 86400; days = t / 86400;
hours = secondsInDay / 3600; secondsInDay = rem t 86400;
minutes = (rem secondsInDay 3600) / 60; hours = secondsInDay / 3600;
seconds = rem t 60; minutes = (rem secondsInDay 3600) / 60;
seconds = rem t 60;
# Courtesy of https://stackoverflow.com/a/32158604. # Courtesy of https://stackoverflow.com/a/32158604.
z = days + 719468; z = days + 719468;
era = era = (if z >= 0 then z else z - 146096) / 146097;
( doe = z - era * 146097;
if z >= 0 yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
then z y = yoe + era * 400;
else z - 146096 doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
) mp = (5 * doy + 2) / 153;
/ 146097; d = doy - (153 * mp + 2) / 5 + 1;
doe = z - era * 146097; m = mp + (if mp < 10 then 3 else -9);
yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365; y' = y + (if m <= 2 then 1 else 0);
y = yoe + era * 400;
doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
mp = (5 * doy + 2) / 153;
d = doy - (153 * mp + 2) / 5 + 1;
m =
mp
+ (
if mp < 10
then 3
else -9
);
y' =
y
+ (
if m <= 2
then 1
else 0
);
pad = s: pad = s: if builtins.stringLength s < 2 then "0" + s else s;
if builtins.stringLength s < 2 in "${toString y'}${pad (toString m)}${pad (toString d)}${pad (toString hours)}${pad (toString minutes)}${pad (toString seconds)}";
then "0" + s
else s;
in "${toString y'}${pad (toString m)}${pad (toString d)}${pad (toString hours)}${pad (toString minutes)}${pad (toString seconds)}";
allNodes = allNodes =
builtins.mapAttrs builtins.mapAttrs
( (key: node:
key: node: let let
sourceInfo = sourceInfo =
if key == lockFile.root if key == lockFile.root
then rootSrc then rootSrc
else fetchTree (node.info or {} // removeAttrs node.locked ["dir"]); else fetchTree (node.info or {} // removeAttrs node.locked ["dir"]);
subdir = subdir = if key == lockFile.root then "" else node.locked.dir or "";
if key == lockFile.root
then ""
else node.locked.dir or "";
flake = import (sourceInfo flake = import (sourceInfo + (if subdir != "" then "/" else "") + subdir + "/flake.nix");
+ (
if subdir != ""
then "/"
else ""
)
+ subdir
+ "/flake.nix");
inputs = inputs = builtins.mapAttrs
builtins.mapAttrs (inputName: inputSpec: allNodes.${resolveInput inputSpec})
(inputName: inputSpec: allNodes.${resolveInput inputSpec}) (node.inputs or {});
(node.inputs or {});
# Resolve a input spec into a node name. An input spec is # Resolve a input spec into a node name. An input spec is
# either a node name, or a 'follows' path from the root # either a node name, or a 'follows' path from the root
# node. # node.
resolveInput = inputSpec: resolveInput = inputSpec:
if builtins.isList inputSpec if builtins.isList inputSpec
then getInputByPath lockFile.root inputSpec then getInputByPath lockFile.root inputSpec
else inputSpec; else inputSpec;
# Follow an input path (e.g. ["dwarffs" "nixpkgs"]) from the # Follow an input path (e.g. ["dwarffs" "nixpkgs"]) from the
# root node, returning the final node. # root node, returning the final node.
getInputByPath = nodeName: path: getInputByPath = nodeName: path:
if path == [] if path == []
then nodeName then nodeName
else
getInputByPath
# Since this could be a 'follows' input, call resolveInput.
(resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path})
(builtins.tail path);
outputs = flake.outputs (inputs // { self = result; });
result = outputs // sourceInfo // { inherit inputs; inherit outputs; inherit sourceInfo; };
in
if node.flake or true then
assert builtins.isFunction flake.outputs;
result
else else
getInputByPath sourceInfo
# Since this could be a 'follows' input, call resolveInput. )
(resolveInput lockFile.nodes.${nodeName}.inputs.${builtins.head path}) lockFile.nodes;
(builtins.tail path);
outputs = flake.outputs (inputs // {self = result;});
result =
outputs
// sourceInfo
// {
inherit inputs;
inherit outputs;
inherit sourceInfo;
};
in
if node.flake or true
then assert builtins.isFunction flake.outputs; result
else sourceInfo
)
lockFile.nodes;
result = result =
if !(builtins.pathExists lockFilePath) if !(builtins.pathExists lockFilePath)
@ -272,30 +189,16 @@
else if lockFile.version >= 5 && lockFile.version <= 7 else if lockFile.version >= 5 && lockFile.version <= 7
then allNodes.${lockFile.root} then allNodes.${lockFile.root}
else throw "lock file '${lockFilePath}' has unsupported version ${toString lockFile.version}"; else throw "lock file '${lockFilePath}' has unsupported version ${toString lockFile.version}";
in rec {
defaultNix =
(builtins.removeAttrs result ["__functor"])
// (
if result ? defaultPackage.${system}
then {default = result.defaultPackage.${system};}
else {}
)
// (
if result ? packages.${system}.default
then {default = result.packages.${system}.default;}
else {}
);
shellNix = in
defaultNix rec {
// ( defaultNix =
if result ? devShell.${system} (builtins.removeAttrs result ["__functor"])
then {default = result.devShell.${system};} // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {})
else {} // (if result ? packages.${system}.default then { default = result.packages.${system}.default; } else {});
)
// ( shellNix =
if result ? devShells.${system}.default defaultNix
then {default = result.devShells.${system}.default;} // (if result ? devShell.${system} then { default = result.devShell.${system}; } else {})
else {} // (if result ? devShells.${system}.default then { default = result.devShells.${system}.default; } else {});
); }
}

View File

@ -1,25 +1,25 @@
let let
pkgs = import ./nixpkgs.nix {config = {allowUnfree = true;};}; pkgs = import ./nixpkgs.nix { config = { allowUnfree = true; }; };
pure = pkgs.recurseIntoAttrs (pkgs.callPackage ./nixGL.nix { pure = pkgs.recurseIntoAttrs (pkgs.callPackage ./nixGL.nix {
nvidiaVersion = "440.82"; nvidiaVersion = "440.82";
nvidiaHash = "edd415acf2f75a659e0f3b4f27c1fab770cf21614e84a18152d94f0d004a758e"; nvidiaHash = "edd415acf2f75a659e0f3b4f27c1fab770cf21614e84a18152d94f0d004a758e";
}); });
versionFile440 = pkgs.callPackage ./nixGL.nix { versionFile440 = (pkgs.callPackage ./nixGL.nix {
nvidiaVersionFile = pkgs.writeText "nvidia-version-440.82" '' nvidiaVersionFile = pkgs.writeText "nvidia-version-440.82" ''
NVRM version: NVIDIA UNIX x86_64 Kernel Module 440.82 Wed Apr 1 20:04:33 UTC 2020 NVRM version: NVIDIA UNIX x86_64 Kernel Module 440.82 Wed Apr 1 20:04:33 UTC 2020
GCC version: gcc version 9.3.0 (Arch Linux 9.3.0-1) GCC version: gcc version 9.3.0 (Arch Linux 9.3.0-1)
''; '';
}; });
versionFile510 = pkgs.callPackage ./nixGL.nix { versionFile510 = (pkgs.callPackage ./nixGL.nix {
nvidiaVersionFile = pkgs.writeText "nvidia-version-510.54" '' nvidiaVersionFile = pkgs.writeText "nvidia-version-510.54" ''
NVRM version: NVIDIA UNIX x86_64 Kernel Module 510.54 Wed Apr 1 20:04:33 UTC 2020 NVRM version: NVIDIA UNIX x86_64 Kernel Module 510.54 Wed Apr 1 20:04:33 UTC 2020
GCC version: gcc version 9.3.0 (Arch Linux 9.3.0-1) GCC version: gcc version 9.3.0 (Arch Linux 9.3.0-1)
''; '';
}; });
in in
(with pure; [nixGLIntel nixVulkanNvidia nixGLNvidia nixVulkanIntel]) (with pure; [ nixGLIntel nixVulkanNvidia nixGLNvidia nixVulkanIntel ])
++ (with versionFile440.auto; [nixGLNvidia nixGLDefault nixVulkanNvidia]) ++ (with versionFile440.auto; [ nixGLNvidia nixGLDefault nixVulkanNvidia ])
++ (with versionFile510.auto; [nixGLNvidia nixGLDefault nixVulkanNvidia]) ++ (with versionFile510.auto; [ nixGLNvidia nixGLDefault nixVulkanNvidia ])

View File

@ -1,41 +1,36 @@
{ {
## Nvidia informations. ## Nvidia informations.
# Version of the system kernel module. Let it to null to enable auto-detection. # Version of the system kernel module. Let it to null to enable auto-detection.
nvidiaVersion ? null, nvidiaVersion ? null
# Hash of the Nvidia driver .run file. null is fine, but fixing a value here , # Hash of the Nvidia driver .run file. null is fine, but fixing a value here
# will be more reproducible and more efficient. # will be more reproducible and more efficient.
nvidiaHash ? null, nvidiaHash ? null
# Alternatively, you can pass a path that points to a nvidia version file , # Alternatively, you can pass a path that points to a nvidia version file
# and let nixGL extract the version from it. That file must be a copy of # and let nixGL extract the version from it. That file must be a copy of
# /proc/driver/nvidia/version. Nix doesn't like zero-sized files (see # /proc/driver/nvidia/version. Nix doesn't like zero-sized files (see
# https://github.com/NixOS/nix/issues/3539 ). # https://github.com/NixOS/nix/issues/3539 ).
nvidiaVersionFile ? null, nvidiaVersionFile ? null
# Enable 32 bits driver , # Enable 32 bits driver
# This is on by default, you can switch it to off if you want to reduce a # This is on by default, you can switch it to off if you want to reduce a
# bit the size of nixGL closure. # bit the size of nixGL closure.
enable32bits ? true, enable32bits ? true
# Make sure to enable config.allowUnfree to the instance of nixpkgs to be , # Make sure to enable config.allowUnfree to the instance of nixpkgs to be
# able to access the nvidia drivers. # able to access the nvidia drivers.
pkgs ? pkgs ? import <nixpkgs> {
import <nixpkgs> { config = { allowUnfree = true; };
config = {allowUnfree = true;}; }
}, , # Enable all Intel specific extensions which only works on x86_64
# Enable all Intel specific extensions which only works on x86_64 enableIntelX86Extensions ? true
enableIntelX86Extensions ? true,
}: }:
pkgs.callPackage ./nixGL.nix ({ pkgs.callPackage ./nixGL.nix ({
inherit inherit
nvidiaVersion nvidiaVersion
nvidiaVersionFile nvidiaVersionFile
nvidiaHash nvidiaHash
enable32bits enable32bits
; ;
} } // (if enableIntelX86Extensions then { }
// ( else {
if enableIntelX86Extensions intel-media-driver = null;
then {} vaapiIntel = null;
else { }))
intel-media-driver = null;
vaapiIntel = null;
}
))

View File

@ -4,46 +4,45 @@
inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:nixos/nixpkgs"; inputs.nixpkgs.url = "github:nixos/nixpkgs";
outputs = { outputs = { self, nixpkgs, flake-utils }:
self, (flake-utils.lib.eachDefaultSystem (system:
nixpkgs, let
flake-utils, isIntelX86Platform = system == "x86_64-linux";
}: nix_pkgs = import nixpkgs { inherit system; };
(flake-utils.lib.eachDefaultSystem (system: let pkgs = import ./default.nix {
isIntelX86Platform = system == "x86_64-linux"; pkgs = nix_pkgs;
nix_pkgs = import nixpkgs {inherit system;};
pkgs = import ./default.nix {
pkgs = nix_pkgs;
enable32bits = isIntelX86Platform;
enableIntelX86Extensions = isIntelX86Platform;
};
in rec {
packages = {
# makes it easy to use "nix run nixGL --impure -- program"
default = pkgs.auto.nixGLDefault;
nixGLDefault = pkgs.auto.nixGLDefault;
nixGLNvidia = pkgs.auto.nixGLNvidia;
nixGLNvidiaBumblebee = pkgs.auto.nixGLNvidiaBumblebee;
nixGLIntel = pkgs.nixGLIntel;
nixVulkanNvidia = pkgs.auto.nixVulkanNvidia;
nixVulkanIntel = pkgs.nixVulkanIntel;
};
# deprecated attributes for retro compatibility
defaultPackage = packages;
}))
// rec {
# deprecated attributes for retro compatibility
overlay = overlays.default;
overlays.default = final: _: let
isIntelX86Platform = final.system == "x86_64-linux";
in {
nixgl = import ./default.nix {
pkgs = final;
enable32bits = isIntelX86Platform; enable32bits = isIntelX86Platform;
enableIntelX86Extensions = isIntelX86Platform; enableIntelX86Extensions = isIntelX86Platform;
}; };
}; in
rec {
packages = {
# makes it easy to use "nix run nixGL --impure -- program"
default = pkgs.auto.nixGLDefault;
nixGLDefault = pkgs.auto.nixGLDefault;
nixGLNvidia = pkgs.auto.nixGLNvidia;
nixGLNvidiaBumblebee = pkgs.auto.nixGLNvidiaBumblebee;
nixGLIntel = pkgs.nixGLIntel;
nixVulkanNvidia = pkgs.auto.nixVulkanNvidia;
nixVulkanIntel = pkgs.nixVulkanIntel;
};
# deprecated attributes for retro compatibility
defaultPackage = packages;
})) // rec {
# deprecated attributes for retro compatibility
overlay = overlays.default;
overlays.default = final: _:
let isIntelX86Platform = final.system == "x86_64-linux";
in {
nixgl = import ./default.nix {
pkgs = final;
enable32bits = isIntelX86Platform;
enableIntelX86Extensions = isIntelX86Platform;
};
};
}; };
} }

View File

@ -1,46 +1,45 @@
{ {
# # Nvidia informations. # # Nvidia informations.
# Version of the system kernel module. Let it to null to enable auto-detection. # Version of the system kernel module. Let it to null to enable auto-detection.
nvidiaVersion ? null, nvidiaVersion ? null
# Hash of the Nvidia driver .run file. null is fine, but fixing a value here , # Hash of the Nvidia driver .run file. null is fine, but fixing a value here
# will be more reproducible and more efficient. # will be more reproducible and more efficient.
nvidiaHash ? null, nvidiaHash ? null
# Alternatively, you can pass a path that points to a nvidia version file , # Alternatively, you can pass a path that points to a nvidia version file
# and let nixGL extract the version from it. That file must be a copy of # and let nixGL extract the version from it. That file must be a copy of
# /proc/driver/nvidia/version. Nix doesn't like zero-sized files (see # /proc/driver/nvidia/version. Nix doesn't like zero-sized files (see
# https://github.com/NixOS/nix/issues/3539 ). # https://github.com/NixOS/nix/issues/3539 ).
nvidiaVersionFile ? null, nvidiaVersionFile ? null
# Enable 32 bits driver , # Enable 32 bits driver
# This is one by default, you can switch it to off if you want to reduce a # This is one by default, you can switch it to off if you want to reduce a
# bit the size of nixGL closure. # bit the size of nixGL closure.
enable32bits ? true, enable32bits ? true
writeTextFile, , writeTextFile
shellcheck, , shellcheck
pcre, , pcre
runCommand, , runCommand
linuxPackages, , linuxPackages
fetchurl, , fetchurl
lib, , lib
runtimeShell, , runtimeShell
bumblebee, , bumblebee
libglvnd, , libglvnd
vulkan-validation-layers, , vulkan-validation-layers
mesa, , mesa
libvdpau-va-gl, , libvdpau-va-gl
intel-media-driver, , intel-media-driver
vaapiIntel, , vaapiIntel
pkgsi686Linux, , pkgsi686Linux
driversi686Linux, , driversi686Linux
zlib, , zlib
libdrm, , libdrm
xorg, , xorg
wayland, , wayland
gcc, , gcc
}: let }:
writeExecutable = {
name, let
text, writeExecutable = { name, text }:
}:
writeTextFile { writeTextFile {
inherit name text; inherit name text;
@ -60,234 +59,230 @@
fetch_db = builtins.fromJSON (builtins.readFile ./nvidia_versions.json); fetch_db = builtins.fromJSON (builtins.readFile ./nvidia_versions.json);
top = rec { top = rec {
/* /*
It contains the builder for different nvidia configuration, parametrized by It contains the builder for different nvidia configuration, parametrized by
the version of the driver and sha256 sum of the driver installer file. the version of the driver and sha256 sum of the driver installer file.
*/ */
nvidiaPackages = { nvidiaPackages = { version, sha256 ? fetch_db."${version}".sha256 }:
version, let
sha256 ? fetch_db."${version}".sha256, nvidiaDrivers = (linuxPackages.nvidia_x11.override { }).overrideAttrs
}: let (oldAttrs: {
nvidiaDrivers = pname = "nvidia";
(linuxPackages.nvidia_x11.override {}).overrideAttrs name = "nvidia-x11-${version}-nixGL";
(oldAttrs: { inherit version;
pname = "nvidia"; src =
name = "nvidia-x11-${version}-nixGL"; let
inherit version; url =
src = let "https://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}.run";
url = "https://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}.run"; in
in fetchurl { inherit url sha256; };
fetchurl {inherit url sha256;}; useGLVND = true;
useGLVND = true; });
}); nvidiaLibsOnly = nvidiaDrivers.override {
nvidiaLibsOnly = nvidiaDrivers.override { libsOnly = true;
libsOnly = true; kernel = null;
kernel = null; };
}; nixNvidiaWrapper = api:
nixNvidiaWrapper = api: writeExecutable {
writeExecutable { name = "nix${api}Nvidia-${version}";
name = "nix${api}Nvidia-${version}"; text = ''
text = '' #!${runtimeShell}
#!${runtimeShell} ${lib.optionalString (api == "Vulkan")
${lib.optionalString (api == "Vulkan")
"export VK_LAYER_PATH=${vulkan-validation-layers}/share/vulkan/explicit_layer.d"} "export VK_LAYER_PATH=${vulkan-validation-layers}/share/vulkan/explicit_layer.d"}
NVIDIA_JSON=(${nvidiaLibsOnly}/share/glvnd/egl_vendor.d/*nvidia.json) NVIDIA_JSON=(${nvidiaLibsOnly}/share/glvnd/egl_vendor.d/*nvidia.json)
${lib.optionalString enable32bits "NVIDIA_JSON32=(${nvidiaLibsOnly.lib32}/share/glvnd/egl_vendor.d/*nvidia.json)"} ${lib.optionalString enable32bits "NVIDIA_JSON32=(${nvidiaLibsOnly.lib32}/share/glvnd/egl_vendor.d/*nvidia.json)"}
${''export __EGL_VENDOR_LIBRARY_FILENAMES=''${NVIDIA_JSON[*]}${ ${''export __EGL_VENDOR_LIBRARY_FILENAMES=''${NVIDIA_JSON[*]}${
lib.optionalString enable32bits lib.optionalString enable32bits
'':''${NVIDIA_JSON32[*]}'' '':''${NVIDIA_JSON32[*]}''
}"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"''} }"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"''
}
${ ${
lib.optionalString (api == "Vulkan") lib.optionalString (api == "Vulkan")
''export VK_ICD_FILENAMES=${nvidiaLibsOnly}/share/vulkan/icd.d/nvidia_icd.json${ ''export VK_ICD_FILENAMES=${nvidiaLibsOnly}/share/vulkan/icd.d/nvidia_icd.json${
lib.optionalString enable32bits lib.optionalString enable32bits
":${nvidiaLibsOnly.lib32}/share/vulkan/icd.d/nvidia_icd.json" ":${nvidiaLibsOnly.lib32}/share/vulkan/icd.d/nvidia_icd.json"
}"''${VK_ICD_FILENAMES:+:$VK_ICD_FILENAMES}"'' }"''${VK_ICD_FILENAMES:+:$VK_ICD_FILENAMES}"''
} }
export LD_LIBRARY_PATH=${ export LD_LIBRARY_PATH=${
lib.makeLibraryPath ([libglvnd nvidiaLibsOnly] lib.makeLibraryPath ([ libglvnd nvidiaLibsOnly ]
++ lib.optional (api == "Vulkan") vulkan-validation-layers ++ lib.optional (api == "Vulkan") vulkan-validation-layers
++ lib.optionals enable32bits [
nvidiaLibsOnly.lib32
pkgsi686Linux.libglvnd
])
}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
exec "$@"
'';
};
in
{
inherit nvidiaDrivers nvidiaLibsOnly;
nixGLNvidiaBumblebee = writeExecutable {
name = "nixGLNvidiaBumblebee-${version}";
text = ''
#!${runtimeShell}
export LD_LIBRARY_PATH=${
lib.makeLibraryPath [ nvidiaDrivers ]
}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
${
bumblebee.override {
nvidia_x11 = nvidiaDrivers;
nvidia_x11_i686 = nvidiaDrivers.lib32;
}
}/bin/optirun --ldpath ${
lib.makeLibraryPath ([ libglvnd nvidiaDrivers ]
++ lib.optionals enable32bits [ ++ lib.optionals enable32bits [
nvidiaLibsOnly.lib32 nvidiaDrivers.lib32
pkgsi686Linux.libglvnd pkgsi686Linux.libglvnd
]) ])
}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" } "$@"
exec "$@"
''; '';
}; };
in {
inherit nvidiaDrivers nvidiaLibsOnly;
nixGLNvidiaBumblebee = writeExecutable { # TODO: 32bit version? Not tested.
name = "nixGLNvidiaBumblebee-${version}"; inherit nixNvidiaWrapper;
text = ''
#!${runtimeShell} # TODO: 32bit version? Not tested.
export LD_LIBRARY_PATH=${ nixGLNvidia = nixNvidiaWrapper "GL";
lib.makeLibraryPath [nvidiaDrivers]
}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" # TODO: 32bit version? Not tested.
${ nixVulkanNvidia = nixNvidiaWrapper "Vulkan";
bumblebee.override {
nvidia_x11 = nvidiaDrivers;
nvidia_x11_i686 = nvidiaDrivers.lib32;
}
}/bin/optirun --ldpath ${
lib.makeLibraryPath ([libglvnd nvidiaDrivers]
++ lib.optionals enable32bits [
nvidiaDrivers.lib32
pkgsi686Linux.libglvnd
])
} "$@"
'';
}; };
# TODO: 32bit version? Not tested.
inherit nixNvidiaWrapper;
# TODO: 32bit version? Not tested.
nixGLNvidia = nixNvidiaWrapper "GL";
# TODO: 32bit version? Not tested.
nixVulkanNvidia = nixNvidiaWrapper "Vulkan";
};
nixGLIntel = writeExecutable { nixGLIntel = writeExecutable {
name = "nixGLIntel"; name = "nixGLIntel";
# add the 32 bits drivers if needed # add the 32 bits drivers if needed
text = let text =
mesa-drivers = let
[mesa.drivers] mesa-drivers = [ mesa.drivers ]
++ lib.optional enable32bits pkgsi686Linux.mesa.drivers; ++ lib.optional enable32bits pkgsi686Linux.mesa.drivers;
intel-driver = intel-driver = [ intel-media-driver vaapiIntel ]
[intel-media-driver vaapiIntel] # Note: intel-media-driver is disabled for i686 until https://github.com/NixOS/nixpkgs/issues/140471 is fixed
# Note: intel-media-driver is disabled for i686 until https://github.com/NixOS/nixpkgs/issues/140471 is fixed ++ lib.optionals enable32bits [ /* pkgsi686Linux.intel-media-driver */ driversi686Linux.vaapiIntel ];
++ lib.optionals enable32bits [ libvdpau = [ libvdpau-va-gl ]
/* ++ lib.optional enable32bits pkgsi686Linux.libvdpau-va-gl;
pkgsi686Linux.intel-media-driver glxindirect = runCommand "mesa_glxindirect" { } (
*/ ''
driversi686Linux.vaapiIntel mkdir -p $out/lib
]; ln -s ${mesa.drivers}/lib/libGLX_mesa.so.0 $out/lib/libGLX_indirect.so.0
libvdpau = ''
[libvdpau-va-gl] );
++ lib.optional enable32bits pkgsi686Linux.libvdpau-va-gl; in
glxindirect = runCommand "mesa_glxindirect" {} '' ''
mkdir -p $out/lib #!${runtimeShell}
ln -s ${mesa.drivers}/lib/libGLX_mesa.so.0 $out/lib/libGLX_indirect.so.0 export LIBGL_DRIVERS_PATH=${lib.makeSearchPathOutput "lib" "lib/dri" mesa-drivers}
''; export LIBVA_DRIVERS_PATH=${lib.makeSearchPathOutput "out" "lib/dri" intel-driver}
in '' ${''export __EGL_VENDOR_LIBRARY_FILENAMES=${mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json${
#!${runtimeShell}
export LIBGL_DRIVERS_PATH=${lib.makeSearchPathOutput "lib" "lib/dri" mesa-drivers}
export LIBVA_DRIVERS_PATH=${lib.makeSearchPathOutput "out" "lib/dri" intel-driver}
${''export __EGL_VENDOR_LIBRARY_FILENAMES=${mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json${
lib.optionalString enable32bits lib.optionalString enable32bits
":${pkgsi686Linux.mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json" ":${pkgsi686Linux.mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json"
}"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"''} }"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"''
export LD_LIBRARY_PATH=${lib.makeLibraryPath mesa-drivers}:${lib.makeSearchPathOutput "lib" "lib/vdpau" libvdpau}:${glxindirect}/lib:${lib.makeLibraryPath [libglvnd]}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" }
exec "$@" export LD_LIBRARY_PATH=${lib.makeLibraryPath mesa-drivers}:${lib.makeSearchPathOutput "lib" "lib/vdpau" libvdpau}:${glxindirect}/lib:${lib.makeLibraryPath [libglvnd]}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
''; exec "$@"
'';
}; };
nixVulkanIntel = writeExecutable { nixVulkanIntel = writeExecutable {
name = "nixVulkanIntel"; name = "nixVulkanIntel";
text = let text =
# generate a file with the listing of all the icd files let
icd = runCommand "mesa_icd" {} ( # generate a file with the listing of all the icd files
# 64 bits icd icd = runCommand "mesa_icd" { } (
'' # 64 bits icd
ls ${mesa.drivers}/share/vulkan/icd.d/*.json > f ''
'' ls ${mesa.drivers}/share/vulkan/icd.d/*.json > f
# 32 bits ones ''
+ lib.optionalString enable32bits '' # 32 bits ones
ls ${pkgsi686Linux.mesa.drivers}/share/vulkan/icd.d/*.json >> f + lib.optionalString enable32bits ''
'' ls ${pkgsi686Linux.mesa.drivers}/share/vulkan/icd.d/*.json >> f
# concat everything as a one line string with ":" as seperator ''
+ ''cat f | xargs | sed "s/ /:/g" > $out'' # concat everything as a one line string with ":" as seperator
); + ''cat f | xargs | sed "s/ /:/g" > $out''
in '' );
#!${runtimeShell} in
if [ -n "$LD_LIBRARY_PATH" ]; then ''
echo "Warning, nixVulkanIntel overwriting existing LD_LIBRARY_PATH" 1>&2 #!${runtimeShell}
fi if [ -n "$LD_LIBRARY_PATH" ]; then
export VK_LAYER_PATH=${vulkan-validation-layers}/share/vulkan/explicit_layer.d echo "Warning, nixVulkanIntel overwriting existing LD_LIBRARY_PATH" 1>&2
ICDS=$(cat ${icd}) fi
export VK_ICD_FILENAMES=$ICDS"''${VK_ICD_FILENAMES:+:$VK_ICD_FILENAMES}" export VK_LAYER_PATH=${vulkan-validation-layers}/share/vulkan/explicit_layer.d
export LD_LIBRARY_PATH=${ ICDS=$(cat ${icd})
lib.makeLibraryPath [ export VK_ICD_FILENAMES=$ICDS"''${VK_ICD_FILENAMES:+:$VK_ICD_FILENAMES}"
zlib export LD_LIBRARY_PATH=${
libdrm lib.makeLibraryPath [
xorg.libX11 zlib
xorg.libxcb libdrm
xorg.libxshmfence xorg.libX11
wayland xorg.libxcb
gcc.cc xorg.libxshmfence
] wayland
}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" gcc.cc
exec "$@" ]
''; }"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
exec "$@"
'';
}; };
nixGLCommon = nixGL: nixGLCommon = nixGL:
runCommand "nixGL" {} '' runCommand "nixGL" { } ''
mkdir -p "$out/bin" mkdir -p "$out/bin"
# star because nixGLNvidia... have version prefixed name # star because nixGLNvidia... have version prefixed name
cp ${nixGL}/bin/* "$out/bin/nixGL"; cp ${nixGL}/bin/* "$out/bin/nixGL";
''; '';
auto = let auto =
_nvidiaVersionFile = let
if nvidiaVersionFile != null _nvidiaVersionFile =
then nvidiaVersionFile if nvidiaVersionFile != null then
else nvidiaVersionFile
else
# HACK: Get the version from /proc. It turns out that /proc is mounted # HACK: Get the version from /proc. It turns out that /proc is mounted
# inside of the build sandbox and varies from machine to machine. # inside of the build sandbox and varies from machine to machine.
# #
# builtins.readFile is not able to read /proc files. See # builtins.readFile is not able to read /proc files. See
# https://github.com/NixOS/nix/issues/3539. # https://github.com/NixOS/nix/issues/3539.
runCommand "impure-nvidia-version-file" runCommand "impure-nvidia-version-file"
{ {
# To avoid sharing the build result over time or between machine, # To avoid sharing the build result over time or between machine,
# Add an impure parameter to force the rebuild on each access. # Add an impure parameter to force the rebuild on each access.
# time = builtins.currentTime; # time = builtins.currentTime;
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false; allowSubstitutes = false;
} "cp /proc/driver/nvidia/version $out 2> /dev/null || touch $out"; } "cp /proc/driver/nvidia/version $out 2> /dev/null || touch $out";
# The nvidia version. Either fixed by the `nvidiaVersion` argument, or # The nvidia version. Either fixed by the `nvidiaVersion` argument, or
# auto-detected. Auto-detection is impure. # auto-detected. Auto-detection is impure.
nvidiaVersionAuto = nvidiaVersionAuto =
if nvidiaVersion != null if nvidiaVersion != null then
then nvidiaVersion nvidiaVersion
else else
# Get if from the nvidiaVersionFile # Get if from the nvidiaVersionFile
let let
data = builtins.readFile _nvidiaVersionFile; data = builtins.readFile _nvidiaVersionFile;
versionMatch = builtins.match ".*Module ([0-9.]+) .*" data; versionMatch = builtins.match ".*Module ([0-9.]+) .*" data;
in in
if versionMatch != null if versionMatch != null then builtins.head versionMatch else null;
then builtins.head versionMatch
else null;
autoNvidia = nvidiaPackages {version = nvidiaVersionAuto;}; autoNvidia = nvidiaPackages { version = nvidiaVersionAuto; };
in in
rec { rec {
# The output derivation contains nixGL which point either to # The output derivation contains nixGL which point either to
# nixGLNvidia or nixGLIntel using an heuristic. # nixGLNvidia or nixGLIntel using an heuristic.
nixGLDefault = nixGLDefault =
if nvidiaVersionAuto != null if nvidiaVersionAuto != null then
then nixGLCommon autoNvidia.nixGLNvidia nixGLCommon autoNvidia.nixGLNvidia
else nixGLCommon nixGLIntel; else
} nixGLCommon nixGLIntel;
// autoNvidia; } // autoNvidia;
}; };
in in
top top // (if nvidiaVersion != null then
// ( top.nvidiaPackages
if nvidiaVersion != null {
then version = nvidiaVersion;
top.nvidiaPackages sha256 = nvidiaHash;
{ }
version = nvidiaVersion; else
sha256 = nvidiaHash; { })
}
else {}
)

View File

@ -1,7 +1,7 @@
let let
rev = "4f6d8095fd51"; rev = "4f6d8095fd51";
in in
import (fetchTarball { import (fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz"; url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz";
sha256 = "14sm0bjjcmi9qmznwy3nkd2vbhj5xcshgm54a5wiprl9ssvxqw53"; sha256 = "14sm0bjjcmi9qmznwy3nkd2vbhj5xcshgm54a5wiprl9ssvxqw53";
}) })

View File

@ -1,29 +1,22 @@
# WARNING: currently not usable anymore
let let
inherit inherit ((import
(( (
import let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
( fetchTarball {
let url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
lock = builtins.fromJSON (builtins.readFile ./flake.lock); sha256 = lock.nodes.flake-compat.locked.narHash;
in }
fetchTarball { )
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; { src = ./.; }
sha256 = lock.nodes.flake-compat.locked.narHash; ).defaultNix) secrets;
}
)
{src = ./.;}
)
.defaultNix)
secrets
;
inherit (secrets) pubKeys; inherit (secrets) pubKeys;
inherit (pubKeys) users hosts; inherit (pubKeys) users hosts;
all = users // hosts; all = users // hosts;
c_ = builtins; c_ = builtins;
in { in
"secrets/s3fs.age".publicKeys = c_.attrValues all; {
"secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues all; "secrets/s3fs.age".publicKeys = c_.attrValues (all);
"secrets/_nhitrl.age".publicKeys = c_.attrValues all; "secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues (all);
"secrets/wifi.env.age".publicKeys = c_.attrValues all; "secrets/_nhitrl.age".publicKeys = c_.attrValues (all);
"secrets/wifi.env.age".publicKeys = c_.attrValues (all);
} }

View File

@ -1,5 +1,6 @@
# TODO: put ssh keys as user/host config # TODO: put ssh keys as user/host config
inputs: let inputs:
let
# user-specific (~/.ssh/id_ed25519.pub) # user-specific (~/.ssh/id_ed25519.pub)
users = { users = {
"hungtr@bao" = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK+1+gps6phbZboIb9fH51VNPUCkhSSOAbkI3tq3Ou0Z"; "hungtr@bao" = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK+1+gps6phbZboIb9fH51VNPUCkhSSOAbkI3tq3Ou0Z";
@ -11,8 +12,9 @@ inputs: let
all = users // systems; all = users // systems;
# stands for calculus # stands for calculus
c_ = builtins; c_ = builtins;
in { in
"system/secrets/s3fs.age".publicKeys = c_.attrValues all; {
"system/secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues all; "system/secrets/s3fs.age".publicKeys = c_.attrValues (all);
"system/secrets/_nhitrl.age".publicKeys = c_.attrValues all; "system/secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues (all);
"system/secrets/_nhitrl.age".publicKeys = c_.attrValues (all);
} }

View File

@ -1,14 +1,11 @@
# This uses the exported devShells from flake.nix # This uses the exported devShells from flake.nix
# the default or base version of nix-shell can be found in dev-shell.nix instead # the default or base version of nix-shell can be found in dev-shell.nix instead
# This architecture is because we use top-level flake.nix # This architecture is because we use top-level flake.nix
( (import
import
( (
let let
lock = builtins.fromJSON (builtins.readFile ./flake.lock); lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in in (import ./c_.nix).fetchTree lock.nodes.flake-compat.locked
(import ./c_.nix).fetchTree lock.nodes.flake-compat.locked
) )
{src = ./.;} { src = ./.; }
) ).shellNix
.shellNix

View File

@ -1,9 +1,8 @@
# TODO: templates should be able to have initial states like # TODO: templates should be able to have initial states like
# repo name, author,... # repo name, author,...
{ { pkgs
pkgs, , lib
lib, , ...
...
}: { }: {
rust = { rust = {
path = ./rust; path = ./rust;

View File

@ -7,5 +7,4 @@
) )
{ {
src = ./.; src = ./.;
}) }).defaultNix
.defaultNix

View File

@ -1,30 +1,29 @@
{ {
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { outputs = { self, nixpkgs }:
self, let
nixpkgs, supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
}: let forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; in
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); {
in { packages = forAllSystems (system: {
packages = forAllSystems (system: { default = pkgs.${system}.poetry2nix.mkPoetryApplication { projectDir = self; };
default = pkgs.${system}.poetry2nix.mkPoetryApplication {projectDir = self;}; });
});
devShells = forAllSystems (system: { devShells = forAllSystems (system: {
bootstrap = pkgs.${system}.mkShellNoCC { bootstrap = pkgs.${system}.mkShellNoCC {
packages = [ packages = [
pkgs.${system}.poetry pkgs.${system}.poetry
]; ];
}; };
default = pkgs.${system}.mkShellNoCC { default = pkgs.${system}.mkShellNoCC {
packages = [ packages = [
(pkgs.${system}.poetry2nix.mkPoetryEnv {projectDir = self;}) (pkgs.${system}.poetry2nix.mkPoetryEnv { projectDir = self; })
pkgs.${system}.poetry pkgs.${system}.poetry
]; ];
}; };
}); });
}; };
} }

View File

@ -7,5 +7,4 @@
) )
{ {
src = ./.; src = ./.;
}) }).shellNix
.shellNix

View File

@ -7,5 +7,4 @@
) )
{ {
src = ./.; src = ./.;
}) }).defaultNix
.defaultNix

View File

@ -6,29 +6,23 @@
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
}; };
outputs = { outputs = { self, nixpkgs, utils, naersk, rust-overlay }:
self, utils.lib.eachDefaultSystem (system:
nixpkgs, let
utils, overlays = [ rust-overlay.overlays.default ];
naersk, pkgs = import nixpkgs { inherit system overlays; };
rust-overlay, rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith
}: (
utils.lib.eachDefaultSystem (system: let toolchain:
overlays = [rust-overlay.overlays.default];
pkgs = import nixpkgs {inherit system overlays;};
rust_pkgs =
pkgs.rust-bin.selectLatestNightlyWith
(
toolchain:
toolchain.default.override { toolchain.default.override {
extensions = ["rust-src" "rust-analyzer" "rust-docs" "clippy" "miri"]; extensions = [ "rust-src" "rust-analyzer" "rust-docs" "clippy" "miri" ];
} }
); ));
naersk-lib = pkgs.callPackage naersk {}; naersk-lib = pkgs.callPackage naersk { };
in { in
defaultPackage = naersk-lib.buildPackage ./.; {
devShell = with pkgs; defaultPackage = naersk-lib.buildPackage ./.;
mkShell { devShell = with pkgs; mkShell {
buildInputs = [ buildInputs = [
rust_pkgs rust_pkgs
# rust's compiler is quite powerful enough to the point where # rust's compiler is quite powerful enough to the point where
@ -43,5 +37,5 @@
# nix flake update # is this even needed? # nix flake update # is this even needed?
''; '';
}; };
}); });
} }

View File

@ -7,5 +7,4 @@
) )
{ {
src = ./.; src = ./.;
}) }).shellNix
.shellNix

View File

@ -7,5 +7,4 @@
) )
{ {
src = ./.; src = ./.;
}) }).defaultNix
.defaultNix

View File

@ -6,29 +6,23 @@
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
}; };
outputs = { outputs = { self, nixpkgs, utils, naersk, rust-overlay }:
self, utils.lib.eachDefaultSystem (system:
nixpkgs, let
utils, overlays = [ rust-overlay.overlays.default ];
naersk, pkgs = import nixpkgs { inherit system overlays; };
rust-overlay, rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith
}: (
utils.lib.eachDefaultSystem (system: let toolchain:
overlays = [rust-overlay.overlays.default];
pkgs = import nixpkgs {inherit system overlays;};
rust_pkgs =
pkgs.rust-bin.selectLatestNightlyWith
(
toolchain:
toolchain.default.override { toolchain.default.override {
extensions = ["rust-src" "rust-analyzer" "rust-docs" "clippy" "miri"]; extensions = [ "rust-src" "rust-analyzer" "rust-docs" "clippy" "miri" ];
} }
); ));
naersk-lib = pkgs.callPackage naersk {}; naersk-lib = pkgs.callPackage naersk { };
in { in
defaultPackage = naersk-lib.buildPackage ./.; {
devShell = with pkgs; defaultPackage = naersk-lib.buildPackage ./.;
mkShell { devShell = with pkgs; mkShell {
buildInputs = [ buildInputs = [
rust_pkgs rust_pkgs
# rust's compiler is quite powerful enough to the point where # rust's compiler is quite powerful enough to the point where
@ -43,5 +37,5 @@
# nix flake update # is this even needed? # nix flake update # is this even needed?
''; '';
}; };
}); });
} }

View File

@ -7,5 +7,4 @@
) )
{ {
src = ./.; src = ./.;
}) }).shellNix
.shellNix

Some files were not shown because too many files have changed in this diff Show More