Compare commits
2 Commits
1537fea0bd
...
6352f821c3
Author | SHA1 | Date |
---|---|---|
Hung | 6352f821c3 | |
Hung | e7efe1a965 |
|
@ -1,5 +1,6 @@
|
|||
# We use top-level nix-flake, so default.nix is basically just a wrapper around ./flake.nix
|
||||
(import
|
||||
(
|
||||
import
|
||||
(
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
|
@ -8,4 +9,5 @@
|
|||
c_.fetchTree lock.nodes.flake-compat.locked
|
||||
)
|
||||
{src = ./.;}
|
||||
).defaultNix
|
||||
)
|
||||
.defaultNix
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
# Should also incorporate shortcuts like scripts/{hm-switch,conf-sysnix}.sh in here instead
|
||||
#
|
||||
# It should not contain PDE
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, lib
|
||||
, ...
|
||||
}: pkgs.mkShell {
|
||||
{
|
||||
pkgs ? import <nixpkgs> {},
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
pkgs.mkShell {
|
||||
# mkShell doesn't care about the differences across nativeBuildInputs,
|
||||
# buildInputs, or packages
|
||||
buildInputs = [
|
||||
|
@ -26,4 +28,3 @@
|
|||
# env vars
|
||||
lol = "hello world";
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
# 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.
|
||||
|
|
@ -429,11 +429,11 @@
|
|||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1686869522,
|
||||
"narHash": "sha256-tbJ9B8WLCTnVP/LwESRlg0dII6Zyg2LmUU/mB9Lu98E=",
|
||||
"lastModified": 1686960236,
|
||||
"narHash": "sha256-AYCC9rXNLpUWzD9hm+askOfpliLEC9kwAo7ITJc4HIw=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "7c67f006ea0e7d0265f16d7df07cc076fdffd91f",
|
||||
"rev": "04af42f3b31dba0ef742d254456dc4c14eedac86",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
20
flake.nix
20
flake.nix
|
@ -9,10 +9,11 @@
|
|||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
deploy-rs.url = "github:serokell/deploy-rs";
|
||||
std.url = "github:divnix/std";
|
||||
hive.url = "github:divnix/hive";
|
||||
rust-overlay = "github:oxalica/rust-overlay.git";
|
||||
};
|
||||
|
||||
outputs = { std, hive, ... }@inputs: std.growOn
|
||||
outputs = {std, ...} @ inputs:
|
||||
std.growOn
|
||||
{
|
||||
# boilerplate
|
||||
inherit inputs;
|
||||
|
@ -21,16 +22,13 @@
|
|||
cellsFrom = ./nix/cells;
|
||||
# modules = ./nix/modules;
|
||||
|
||||
cellBlocks =
|
||||
let
|
||||
cellBlocks = let
|
||||
inherit (std.blockTypes) devshells functions;
|
||||
in
|
||||
[
|
||||
in [
|
||||
(devshells "devshells")
|
||||
(devshells "userShells")
|
||||
# (functions "host_profile")
|
||||
# (functions "home_profile")
|
||||
|
||||
(functions "home-profiles")
|
||||
(functions "home-modules")
|
||||
];
|
||||
}
|
||||
{
|
||||
|
@ -38,5 +36,9 @@
|
|||
# nixosConfigurations = std.pick [ [ "dotfiles" "nixos" ] ];
|
||||
# homeConfigurations = std.pick [ [ "dotfiles" "home" ] ];
|
||||
homeModules = std.pick [["repo" "home-modules"]];
|
||||
|
||||
# TODO: Debug only
|
||||
homeProfiles = std.pick [["repo" "home-profiles"]];
|
||||
packages = std.harvest [["repo" "home-configs"]];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [];
|
||||
|
||||
boot.initrd.availableKernelModules = [];
|
||||
|
@ -43,20 +47,17 @@
|
|||
# fsType = "drvfs";
|
||||
# };
|
||||
|
||||
fileSystems."/mnt/c" =
|
||||
{
|
||||
fileSystems."/mnt/c" = {
|
||||
device = "C:";
|
||||
fsType = "drvfs";
|
||||
};
|
||||
|
||||
fileSystems."/mnt/d" =
|
||||
{
|
||||
fileSystems."/mnt/d" = {
|
||||
device = "D:";
|
||||
fsType = "drvfs";
|
||||
};
|
||||
|
||||
fileSystems."/mnt/f" =
|
||||
{
|
||||
fileSystems."/mnt/f" = {
|
||||
device = "F:";
|
||||
fsType = "drvfs";
|
||||
};
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{ nixpkgs
|
||||
, agenix
|
||||
, home-manager
|
||||
, flake-utils
|
||||
, nixgl
|
||||
, rust-overlay
|
||||
, flake-compat
|
||||
, pkgs
|
||||
, lib
|
||||
, proj_root
|
||||
{
|
||||
nixpkgs,
|
||||
agenix,
|
||||
home-manager,
|
||||
flake-utils,
|
||||
nixgl,
|
||||
rust-overlay,
|
||||
flake-compat,
|
||||
pkgs,
|
||||
lib,
|
||||
proj_root,
|
||||
}: {}
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
{ nixpkgs
|
||||
, agenix
|
||||
, home-manager
|
||||
, flake-utils
|
||||
, nixgl
|
||||
, rust-overlay
|
||||
, flake-compat
|
||||
, pkgs
|
||||
, lib
|
||||
, proj_root
|
||||
, nixosDefaultVersion ? "22.05"
|
||||
, defaultSystem ? "x86_64-linux"
|
||||
, ...
|
||||
}@finalInputs:
|
||||
let
|
||||
{
|
||||
nixpkgs,
|
||||
agenix,
|
||||
home-manager,
|
||||
flake-utils,
|
||||
nixgl,
|
||||
rust-overlay,
|
||||
flake-compat,
|
||||
pkgs,
|
||||
lib,
|
||||
proj_root,
|
||||
nixosDefaultVersion ? "22.05",
|
||||
defaultSystem ? "x86_64-linux",
|
||||
...
|
||||
} @ finalInputs: let
|
||||
config = {
|
||||
bao.metadata = {
|
||||
# req
|
||||
|
@ -33,8 +33,10 @@ let
|
|||
];
|
||||
};
|
||||
};
|
||||
propagate = hostConfig@{ metadata, nixosConfig }:
|
||||
let
|
||||
propagate = hostConfig @ {
|
||||
metadata,
|
||||
nixosConfig,
|
||||
}: let
|
||||
# req
|
||||
inherit (metadata) hostName;
|
||||
# opts
|
||||
|
@ -47,12 +49,14 @@ let
|
|||
hardwareConfig = import "${proj_root.hosts.path}/${hostName}/hardware-configuration.nix";
|
||||
# alias to prevent infinite recursion
|
||||
_nixosConfig = nixosConfig;
|
||||
in
|
||||
{
|
||||
in {
|
||||
inherit hostName ssh_pubkey users nixosVersion system preset hardwareConfig;
|
||||
nixosConfig = _nixosConfig // {
|
||||
nixosConfig =
|
||||
_nixosConfig
|
||||
// {
|
||||
inherit system;
|
||||
modules = [
|
||||
modules =
|
||||
[
|
||||
{
|
||||
config._module.args = {
|
||||
inherit proj_root;
|
||||
|
@ -71,7 +75,8 @@ let
|
|||
}
|
||||
(import "${proj_root.modules.path}/secrets.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
|
||||
|
@ -79,8 +84,7 @@ let
|
|||
mkHost = hostConfig: (lib.pipe [propagate mkHostFromPropagated] hostConfig);
|
||||
trimNull = lib.filterAttrsRecursive (name: value: value != null);
|
||||
flattenPubkey = lib.mapAttrs (hostName: meta_config: meta_config.metadata.ssh_pubkey);
|
||||
in
|
||||
{
|
||||
in {
|
||||
nixosConfigurations = lib.mapAttrs (name: hostConfig: mkHost hostConfig) config;
|
||||
# {bao = "ssh-ed25519 ..."; another_host = "ssh-rsa ...";}
|
||||
pubKeys = lib.getPubkey config;
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
|
@ -23,14 +26,12 @@
|
|||
boot.kernelModules = [];
|
||||
boot.extraModulePackages = [];
|
||||
|
||||
fileSystems."/" =
|
||||
{
|
||||
fileSystems."/" = {
|
||||
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
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
|
@ -23,14 +26,12 @@
|
|||
boot.kernelModules = [];
|
||||
boot.extraModulePackages = [];
|
||||
|
||||
fileSystems."/" =
|
||||
{
|
||||
fileSystems."/" = {
|
||||
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
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
{ nixpkgs
|
||||
, agenix
|
||||
, home-manager
|
||||
, flake-utils
|
||||
, nixgl
|
||||
, rust-overlay
|
||||
, flake-compat
|
||||
, pkgs
|
||||
, lib
|
||||
, proj_root
|
||||
{
|
||||
nixpkgs,
|
||||
agenix,
|
||||
home-manager,
|
||||
flake-utils,
|
||||
nixgl,
|
||||
rust-overlay,
|
||||
flake-compat,
|
||||
pkgs,
|
||||
lib,
|
||||
proj_root,
|
||||
}: {}
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
|
@ -35,8 +38,7 @@
|
|||
};
|
||||
};
|
||||
|
||||
swapDevices =
|
||||
[{ device = "/dev/sdb"; }];
|
||||
swapDevices = [{device = "/dev/sdb";}];
|
||||
|
||||
# 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
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
|
@ -23,14 +26,12 @@
|
|||
boot.loader.grub.forceInstall = true;
|
||||
boot.loader.grub.device = "nodev";
|
||||
boot.loader.timeout = 10;
|
||||
fileSystems."/" =
|
||||
{
|
||||
fileSystems."/" = {
|
||||
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
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{ pkgs
|
||||
, lib
|
||||
, proj_root
|
||||
, ...
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
proj_root,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
./minimal.sys.nix
|
||||
|
@ -11,5 +12,4 @@
|
|||
];
|
||||
environment.systemPackages = [pkgs.lm_sensors];
|
||||
time.timeZone = "America/Phoenix";
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{ pkgs
|
||||
, my-lib
|
||||
, ...
|
||||
{
|
||||
pkgs,
|
||||
my-lib,
|
||||
...
|
||||
}: {
|
||||
environment.noXlibs = my-lib.mkForce false;
|
||||
# TODO: wireless networking
|
||||
|
@ -11,8 +12,9 @@
|
|||
services.xserver.displayManager.sddm.enable = true;
|
||||
services.xserver.desktopManager.plasma5 = {
|
||||
enable = true;
|
||||
excludePackages = let plasma5 = pkgs.libsForQt5; in
|
||||
[
|
||||
excludePackages = let
|
||||
plasma5 = pkgs.libsForQt5;
|
||||
in [
|
||||
plasma5.elisa # audio viewer
|
||||
plasma5.konsole # I use alacritty instaed
|
||||
plasma5.plasma-browser-integration
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{ pkgs
|
||||
, lib
|
||||
, proj_root
|
||||
, modulesPath
|
||||
, ...
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
proj_root,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = ["${modulesPath}/profiles/minimal.nix"];
|
||||
# prune old builds after a while
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
{ pkgs
|
||||
, lib
|
||||
, config
|
||||
, ...
|
||||
}:
|
||||
let cfg = config.mod.mosh; in
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.mod.mosh;
|
||||
in {
|
||||
options.mod.mosh = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
|
@ -17,9 +18,11 @@ let cfg = config.mod.mosh; in
|
|||
environment.systemPackages = [pkgs.mosh];
|
||||
networking.firewall = lib.mkIf config.networking.firewall.enable {
|
||||
allowedUDPPortRanges = [
|
||||
{ from = 60000; to = 61000; } # mosh
|
||||
{
|
||||
from = 60000;
|
||||
to = 61000;
|
||||
} # mosh
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
{ config, pkgs, lib }:
|
||||
let
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
}: let
|
||||
gpu_pkgs = [pkgs.clinfo pkgs.lshw pkgs.glxinfo pkgs.pciutils pkgs.vulkan-tools];
|
||||
gpu_conf = {
|
||||
# openCL
|
||||
hardware.opengl = {
|
||||
enable = true;
|
||||
extraPackages =
|
||||
let
|
||||
extraPackages = let
|
||||
inherit (pkgs) rocm-opencl-icd rocm-opencl-runtime;
|
||||
in
|
||||
[ rocm-opencl-icd rocm-opencl-runtime ];
|
||||
in [rocm-opencl-icd rocm-opencl-runtime];
|
||||
# Vulkan
|
||||
driSupport = true;
|
||||
driSupport32Bit = true;
|
||||
|
@ -18,4 +19,5 @@ let
|
|||
};
|
||||
environment.systemPackages = gpu_pkgs;
|
||||
};
|
||||
in gpu_conf
|
||||
in
|
||||
gpu_conf
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
{ proj_root
|
||||
, ...
|
||||
}: {
|
||||
{proj_root, ...}: {
|
||||
age.secrets.s3fs = {
|
||||
file = "${proj_root.secrets.path}/s3fs.age";
|
||||
# mode = "600"; # owner + group only
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
# Personal configuration on storage solution
|
||||
{ pkgs, config, lib, ... }: {
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
environment.systemPackages = [
|
||||
pkgs.s3fs
|
||||
pkgs.cifs-utils
|
||||
|
@ -9,8 +14,7 @@
|
|||
# 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
|
||||
# TODO: make this configuration nix-less to show that it's 100% data
|
||||
services.autofs =
|
||||
let
|
||||
services.autofs = let
|
||||
# confToBackendArg {lol="what"; empty=""; name_only=null;} -> "lol=what,empty=,name_only"
|
||||
# TODO: change null -> true/false. This allows overriding & better self-documentation
|
||||
confToBackendArg = conf: (lib.concatStringsSep ","
|
||||
|
@ -24,15 +28,13 @@
|
|||
# backend_args, so just put the bucket name here
|
||||
#
|
||||
#-> "${mount_dest} ${formatted_args} ${s3fs-bin}#${bucket}"
|
||||
autofs-s3fs_entry =
|
||||
{ mount_dest
|
||||
, backend_args ? { "-fstype" = "fuse"; }
|
||||
, bucket
|
||||
}@inputs:
|
||||
let
|
||||
autofs-s3fs_entry = {
|
||||
mount_dest,
|
||||
backend_args ? {"-fstype" = "fuse";},
|
||||
bucket,
|
||||
} @ inputs: let
|
||||
s3fs-exec = "${pkgs.s3fs}/bin/s3fs";
|
||||
in
|
||||
"${mount_dest} ${confToBackendArg backend_args} :${s3fs-exec}\#${bucket}";
|
||||
in "${mount_dest} ${confToBackendArg backend_args} :${s3fs-exec}\#${bucket}";
|
||||
personalStorage = [
|
||||
(autofs-s3fs_entry {
|
||||
mount_dest = "garden";
|
||||
|
@ -61,8 +63,7 @@
|
|||
dir_mode = "0777";
|
||||
file_mode = "0777";
|
||||
};
|
||||
in
|
||||
"felia_d ${confToBackendArg args} ://felia.coati-celsius.ts.net/d"
|
||||
in "felia_d ${confToBackendArg args} ://felia.coati-celsius.ts.net/d"
|
||||
)
|
||||
(
|
||||
let
|
||||
|
@ -75,13 +76,11 @@
|
|||
dir_mode = "0777";
|
||||
file_mode = "0777";
|
||||
};
|
||||
in
|
||||
"felia_f ${confToBackendArg args} ://felia.coati-celsius.ts.net/f"
|
||||
in "felia_f ${confToBackendArg args} ://felia.coati-celsius.ts.net/f"
|
||||
)
|
||||
];
|
||||
persoConf = pkgs.writeText "auto.personal" (builtins.concatStringsSep "\n" personalStorage);
|
||||
in
|
||||
{
|
||||
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
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
{ pkgs
|
||||
, config
|
||||
, lib
|
||||
, ...
|
||||
}: let cfg = config.mod.tailscale; in {
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.mod.tailscale;
|
||||
in {
|
||||
options.mod.tailscale = {
|
||||
enable = lib.mkEnableOption "tailscale";
|
||||
};
|
||||
|
|
|
@ -5,8 +5,13 @@ Contains all configurations that are written in their native configuration langu
|
|||
## Why native language?
|
||||
|
||||
- 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),
|
||||
[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),
|
||||
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
|
||||
|
||||
|
|
|
@ -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('folke/todo-comments.nvim') -- Highlights TODO
|
||||
WPlug('NvChad/nvim-colorizer.lua') -- color highlighter with tailwind support
|
||||
WPlug('roobert/tailwindcss-colorizer-cmp.nvim') -- color highlighter with tailwind support
|
||||
WPlug('roobert/tailwindcss-colorizer-cmp.nvim') -- color for tailiwnd for compe
|
||||
|
||||
-- other utilities
|
||||
WPlug('nvim-treesitter/nvim-treesitter-context') -- Top one-liner context of func/class scope
|
||||
|
@ -112,6 +112,7 @@ WPlug('nvim-treesitter/playground') -- Sees Treesitter AST - less h
|
|||
WPlug('saadparwaiz1/cmp_luasnip') -- snippet engine
|
||||
WPlug('L3MON4D3/LuaSnip') -- snippet engine
|
||||
WPlug('mickael-menu/zk-nvim') -- Zettelkasten
|
||||
WPlug('folke/neodev.nvim') -- Neovim + lua development setup
|
||||
-- Switch cases:
|
||||
-- `gsp` -> PascalCase (classes), `gsc` -> camelCase (Java), `gs_` -> snake_case (C/C++/Rust)
|
||||
-- `gsu` -> UPPER_CASE (CONSTs), `gsk` -> kebab-case (Clojure), `gsK` -> Title-Kebab-Case
|
||||
|
@ -241,7 +242,57 @@ colorscheme gruvbox
|
|||
]])
|
||||
require('hlargs').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?
|
||||
require('todo-comments').setup()
|
||||
|
@ -922,10 +973,10 @@ require('mason-lspconfig').setup_handlers({
|
|||
defaultConfig = {
|
||||
indent_style = "space",
|
||||
indent_size = 4,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
["pyright"] = function()
|
||||
|
@ -993,6 +1044,29 @@ require('mason-lspconfig').setup_handlers({
|
|||
},
|
||||
}
|
||||
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 {
|
||||
tools = {
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
{ config
|
||||
, proj_root
|
||||
, myLib
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
{
|
||||
config,
|
||||
proj_root,
|
||||
myLib,
|
||||
...
|
||||
}: let
|
||||
inherit (myLib) fromYaml;
|
||||
actualConfig = fromYaml (builtins.readFile "${proj_root.config.path}//alacritty/alacritty.yml");
|
||||
cfg = config.base.alacritty;
|
||||
in
|
||||
{
|
||||
options.base.alacritty =
|
||||
{
|
||||
in {
|
||||
options.base.alacritty = {
|
||||
font.family = myLib.mkOption {
|
||||
type = myLib.types.singleLineStr;
|
||||
default = actualConfig.font.normal.family;
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
{ lib, pkgs, config, ... }:
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
# This patch exists since Darwin's search bar requires solid apps and not
|
||||
# symlinked
|
||||
# TODO: QA
|
||||
|
@ -11,8 +15,8 @@
|
|||
# Copy GUI apps to "~/Applications/Home Manager Apps"
|
||||
# Based on this comment: https://github.com/nix-community/home-manager/issues/1341#issuecomment-778820334
|
||||
home.activation.patch-spotlight =
|
||||
if pkgs.stdenv.isDarwin then
|
||||
let
|
||||
if pkgs.stdenv.isDarwin
|
||||
then let
|
||||
apps = pkgs.buildEnv {
|
||||
name = "home-manager-applications";
|
||||
paths = config.home.packages;
|
||||
|
@ -33,12 +37,12 @@
|
|||
$DRY_RUN_CMD cp --archive -H --dereference ${apps}/Applications/* "$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
|
||||
# applications
|
||||
home.activation.remove-patch-spotlight =
|
||||
if pkgs.stdenv.isDarwin then
|
||||
if pkgs.stdenv.isDarwin
|
||||
then
|
||||
lib.hm.dag.entryBefore ["checkLinkTargets"] ''
|
||||
HM_APPS="$HOME/Applications/Home Manager Apps"
|
||||
# Reset current state
|
||||
|
@ -46,6 +50,5 @@
|
|||
$DRY_RUN_CMD mv "$HM_APPS" "$HM_APPS.$(date +%Y%m%d%H%M%S)"
|
||||
fi
|
||||
''
|
||||
else
|
||||
"";
|
||||
else "";
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
{nix-index-database
|
||||
,...
|
||||
}@inputs:{
|
||||
{nix-index-database, ...} @ inputs: {
|
||||
mkModuleArgs = import ./mkModuleArgs.nix;
|
||||
modules = [
|
||||
./alacritty.nix
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{ config
|
||||
, myLib
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
{
|
||||
config,
|
||||
myLib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.base.git;
|
||||
baseAliases = {
|
||||
a = "add";
|
||||
|
@ -15,8 +15,7 @@ let
|
|||
co = "checkout";
|
||||
b = "branch";
|
||||
};
|
||||
in
|
||||
{
|
||||
in {
|
||||
options.base.git = {
|
||||
aliases = myLib.mkOption {
|
||||
type = myLib.types.attrs;
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
let
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.base.graphics;
|
||||
cfgEnable = cfg.enable or (cfg.useNixGL.defaultPackage != null);
|
||||
types = lib.types;
|
||||
in
|
||||
{
|
||||
in {
|
||||
imports = [./shells.nix];
|
||||
options.base.graphics = {
|
||||
enable = lib.mkEnableOption "graphics";
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
{ config, proj_root, pkgs, lib, ... }:
|
||||
let
|
||||
{
|
||||
config,
|
||||
proj_root,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.base.keepass;
|
||||
trimNull = lib.filterAttrsRecursive (name: value: value != null);
|
||||
in
|
||||
{
|
||||
in {
|
||||
imports = [./graphics.nix];
|
||||
options.base.keepass = {
|
||||
enable = lib.mkEnableOption "keepass";
|
||||
|
@ -42,11 +46,17 @@ in
|
|||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = [
|
||||
home.packages =
|
||||
[
|
||||
pkgs.kpcli-py # kp but is in cli
|
||||
] ++ (if cfg.use_gui or config.base.graphics._enable then [
|
||||
]
|
||||
++ (
|
||||
if cfg.use_gui or config.base.graphics._enable
|
||||
then [
|
||||
pkgs.keepass # Personal secret management
|
||||
] else [ ]);
|
||||
]
|
||||
else []
|
||||
);
|
||||
home.file.".kp/config.ini".text = lib.generators.toINI {} (trimNull {
|
||||
default = {
|
||||
KEEPASSDB = cfg.path;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# Turns given inputs into the standardized shape of the inputs to configure
|
||||
# custom base modules in this directory.
|
||||
{ pkgs
|
||||
, lib ? pkgs.lib
|
||||
, ...
|
||||
}@inputs:
|
||||
let
|
||||
{
|
||||
pkgs,
|
||||
lib ? pkgs.lib,
|
||||
...
|
||||
} @ inputs: let
|
||||
recursiveUpdate = lib.recursiveUpdate;
|
||||
_lib = recursiveUpdate lib (import ../../lib {inherit pkgs lib;});
|
||||
proj_root = builtins.toString ./../../..;
|
||||
|
|
|
@ -2,22 +2,29 @@
|
|||
#
|
||||
# One thing to consider, though, /nix/store of `nix-shell` or `nix-develop`
|
||||
# might be different from `home-manager`'s (~/.nix_profile/bin/jq)
|
||||
{ pkgs, lib, config, proj_root, ... }:
|
||||
let
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
proj_root,
|
||||
...
|
||||
}: let
|
||||
# NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace
|
||||
# and is added to the path after wrapping.
|
||||
# check: nix repl `homeConfigurations.hungtr.config.programs.neovim.finalPackage.buildCommand`
|
||||
# see: :/--suffix.*PATH
|
||||
# there should be mentions of additional packages
|
||||
my_neovim = pkgs.neovim-unwrapped;
|
||||
rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith
|
||||
rust_pkgs =
|
||||
pkgs.rust-bin.selectLatestNightlyWith
|
||||
(
|
||||
toolchain:
|
||||
toolchain.default.override {
|
||||
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
|
||||
|
@ -48,22 +55,33 @@ let
|
|||
# pkgs.rust-analyzer
|
||||
# rust_pkgs
|
||||
# pkgs.evcxr # Rust REPL for Conjure!
|
||||
] ++ lib.optionals (pkgs.stdenv.isDarwin) (
|
||||
]
|
||||
++ lib.optionals (pkgs.stdenv.isDarwin) (
|
||||
let
|
||||
inherit (pkgs.darwin.apple_sdk.frameworks) System CoreFoundation; in
|
||||
[
|
||||
inherit (pkgs.darwin.apple_sdk.frameworks) System CoreFoundation;
|
||||
in [
|
||||
System
|
||||
CoreFoundation
|
||||
]
|
||||
);
|
||||
in
|
||||
{
|
||||
in {
|
||||
options.base.neovim = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
description = "enable personalized neovim as default editor";
|
||||
type = lib.types.bool;
|
||||
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 {
|
||||
|
@ -76,30 +94,25 @@ in
|
|||
withPython3 = true;
|
||||
withNodeJs = true;
|
||||
extraPackages = nvim_pkgs;
|
||||
extraLuaConfig = (builtins.readFile "${proj_root.config.path}//neovim/init.lua");
|
||||
plugins = (let inherit (pkgs.vimPlugins)
|
||||
extraLuaConfig = builtins.readFile "${proj_root.config.path}//neovim/init.lua";
|
||||
plugins = let
|
||||
inherit
|
||||
(pkgs.vimPlugins)
|
||||
plenary-nvim
|
||||
|
||||
nvim-treesitter
|
||||
nvim-treesitter-textobjects
|
||||
nvim-treesitter-context
|
||||
|
||||
telescope-fzf-native-nvim
|
||||
telescope-file-browser-nvim
|
||||
telescope-nvim
|
||||
|
||||
nvim-lspconfig
|
||||
|
||||
gruvbox-community
|
||||
|
||||
neodev-nvim
|
||||
|
||||
cmp-nvim-lsp
|
||||
cmp-path
|
||||
cmp-buffer
|
||||
cmp-cmdline
|
||||
nvim-cmp
|
||||
|
||||
lspkind-nvim
|
||||
nvim-autopairs
|
||||
nvim-ts-autotag
|
||||
|
@ -109,7 +122,6 @@ in
|
|||
luasnip
|
||||
fidget-nvim
|
||||
rust-tools-nvim
|
||||
|
||||
cmp_luasnip
|
||||
gitsigns-nvim
|
||||
indent-blankline-nvim
|
||||
|
@ -128,8 +140,8 @@ in
|
|||
vim-dispatch-neovim
|
||||
vim-fugitive
|
||||
vim-jack-in
|
||||
|
||||
; in [
|
||||
;
|
||||
in [
|
||||
plenary-nvim
|
||||
nvim-treesitter.withAllGrammars
|
||||
nvim-treesitter-textobjects
|
||||
|
@ -173,7 +185,7 @@ in
|
|||
vim-dispatch-neovim
|
||||
vim-fugitive
|
||||
vim-jack-in
|
||||
]);
|
||||
];
|
||||
};
|
||||
# home.packages = nvim_pkgs;
|
||||
};
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
# TODO: maybe throw if base.graphics is not enabled?
|
||||
# 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 = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
|
@ -19,26 +23,29 @@ in
|
|||
programs.chromium = {
|
||||
enable = true;
|
||||
package = pkgs.ungoogled-chromium;
|
||||
extensions =
|
||||
let
|
||||
extensions = let
|
||||
# TODO: how about a chrome extension registry?
|
||||
mkChromiumExtForVersion = browserVersion: { id, sha256, extVersion, ... }:
|
||||
{
|
||||
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";
|
||||
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
|
||||
[
|
||||
in [
|
||||
# vimium
|
||||
(mkChromiumExt {
|
||||
id = "dbepggeogbaibhgnhhndojpepiihcmeb";
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
# Configurations for shell stuffs.
|
||||
# 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 = {
|
||||
enable = myLib.mkOption {
|
||||
type = myLib.types.bool;
|
||||
|
@ -53,7 +53,7 @@ in
|
|||
enable = true;
|
||||
# extraConfigBeforePlugin = builtins.readFile "${proj_root.config.path}/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");
|
||||
extraConfig = builtins.readFile "${proj_root.config.path}/tmux/tmux.conf";
|
||||
};
|
||||
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 '
|
||||
|
@ -69,13 +69,14 @@ in
|
|||
enableZshIntegration = true;
|
||||
settings = let
|
||||
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 = [
|
||||
["nix" "run" "nixpkgs#clang" "--" "--version"]
|
||||
["nix" "run" "nixpkgs#gcc" "--" "--version"]
|
||||
];
|
||||
});
|
||||
in patch-nix;
|
||||
};
|
||||
in
|
||||
patch-nix;
|
||||
};
|
||||
# Fuzzy finder. `fzf` for TUI, `fzf -f '<fuzzy query>'` for UNIX piping
|
||||
programs.fzf.enable = true;
|
||||
|
@ -88,10 +89,12 @@ in
|
|||
enable = true;
|
||||
enableCompletion = true;
|
||||
enableAutosuggestions = true;
|
||||
shellAliases = {
|
||||
shellAliases =
|
||||
{
|
||||
nix-rebuild = "sudo nixos-rebuild switch";
|
||||
hm-switch = "home-manager switch --flake";
|
||||
} // (cfg.shellAliases or { });
|
||||
}
|
||||
// (cfg.shellAliases or {});
|
||||
history = {
|
||||
size = 10000;
|
||||
path = "${config.xdg.dataHome}/zsh/history";
|
||||
|
@ -119,10 +122,11 @@ in
|
|||
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 :)
|
||||
};
|
||||
initExtra = (cfg.shellInitExtra or "") + ''
|
||||
initExtra =
|
||||
(cfg.shellInitExtra or "")
|
||||
+ ''
|
||||
source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
|
||||
'';
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
type = myLib.types.bool;
|
||||
default = true;
|
||||
|
@ -20,4 +20,3 @@ in
|
|||
includes = ["${proj_root.config.path}/ssh/config"];
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# We use top-level nix-flake, so default.nix is basically just a wrapper around ./flake.nix
|
||||
(import
|
||||
(
|
||||
import
|
||||
(
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
|
@ -8,4 +9,5 @@
|
|||
c_.fetchTree lock.nodes.flake-compat.locked
|
||||
)
|
||||
{src = ./.;}
|
||||
).defaultNix
|
||||
)
|
||||
.defaultNix
|
||||
|
|
|
@ -833,11 +833,11 @@
|
|||
},
|
||||
"nixpkgs-latest": {
|
||||
"locked": {
|
||||
"lastModified": 1686940302,
|
||||
"narHash": "sha256-hTBVlV53sfi7ZyTkRKIVZy3V26ixnWGZnYrHvb9rCZU=",
|
||||
"lastModified": 1687044368,
|
||||
"narHash": "sha256-7eBtV3lgfgjeyBDa20Xr4O9mlcAHHFYpvo6m16tgLcY=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1f5b5df0d309144d10d409d161b50adc94157ef6",
|
||||
"rev": "b621273236ab985db5ff7e91171624f2e07e82a1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -882,11 +882,11 @@
|
|||
},
|
||||
"nixpkgs_10": {
|
||||
"locked": {
|
||||
"lastModified": 1686869522,
|
||||
"narHash": "sha256-tbJ9B8WLCTnVP/LwESRlg0dII6Zyg2LmUU/mB9Lu98E=",
|
||||
"lastModified": 1686960236,
|
||||
"narHash": "sha256-AYCC9rXNLpUWzD9hm+askOfpliLEC9kwAo7ITJc4HIw=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "7c67f006ea0e7d0265f16d7df07cc076fdffd91f",
|
||||
"rev": "04af42f3b31dba0ef742d254456dc4c14eedac86",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1327,11 +1327,11 @@
|
|||
"nixpkgs": "nixpkgs_11"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1686882360,
|
||||
"narHash": "sha256-6iWVGIdIzmx/CgXPVLPyyxxBhPGYMl8sG09S8hpQ6pc=",
|
||||
"lastModified": 1686968542,
|
||||
"narHash": "sha256-Gjlj7UeHqMFRAYyefeoLnSjLo8V+0XheIamojNEyTbE=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "b519b1d7a31f1bd35423990398adecc6f7dd4dd2",
|
||||
"rev": "01d84cd842e48e89be67e4c2d9dc46aa7709adc5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -43,31 +43,32 @@
|
|||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
flake_inputs@{ nixpkgs
|
||||
, home-manager
|
||||
, nixgl
|
||||
, rust-overlay
|
||||
, flake-utils
|
||||
, kpcli-py
|
||||
, neovim-nightly-overlay
|
||||
, nix-boost
|
||||
, nixpkgs-latest
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
outputs = flake_inputs @ {
|
||||
nixpkgs,
|
||||
home-manager,
|
||||
nixgl,
|
||||
rust-overlay,
|
||||
flake-utils,
|
||||
kpcli-py,
|
||||
neovim-nightly-overlay,
|
||||
nix-boost,
|
||||
nixpkgs-latest,
|
||||
...
|
||||
}: let
|
||||
# config_fn:: system -> config
|
||||
cross_platform = config_fn: ({
|
||||
packages = builtins.foldl'
|
||||
(prev: system: prev // {
|
||||
cross_platform = config_fn: {
|
||||
packages =
|
||||
builtins.foldl'
|
||||
(prev: system:
|
||||
prev
|
||||
// {
|
||||
"${system}" = config_fn system;
|
||||
})
|
||||
{}
|
||||
flake-utils.lib.defaultSystems;
|
||||
});
|
||||
};
|
||||
in
|
||||
cross_platform (system:
|
||||
let
|
||||
cross_platform (system: let
|
||||
overlays = import ./overlays.nix (flake_inputs // {inherit system;});
|
||||
# pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays;
|
||||
pkgs = import nixpkgs {
|
||||
|
@ -78,7 +79,11 @@
|
|||
base = import ./base flake_inputs;
|
||||
inherit (base) mkModuleArgs;
|
||||
|
||||
nerd_font_module = { config, pkgs, ... }: {
|
||||
nerd_font_module = {
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
fonts.fontconfig.enable = true;
|
||||
home.packages = [
|
||||
# list of fonts are available at https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/data/fonts/nerdfonts/shas.nix
|
||||
|
@ -86,23 +91,22 @@
|
|||
];
|
||||
base.alacritty.font.family = "Hack Nerd Font Mono";
|
||||
};
|
||||
in
|
||||
{
|
||||
in {
|
||||
debug = {
|
||||
inherit overlays pkgs base;
|
||||
};
|
||||
homeConfigurations =
|
||||
let
|
||||
homeConfigurations = let
|
||||
x11_wsl = ''
|
||||
# x11 output for WSL
|
||||
export DISPLAY=$(ip route list default | awk '{print $3}'):0
|
||||
export LIBGL_ALWAYS_INDIRECT=1
|
||||
'';
|
||||
in
|
||||
{
|
||||
in {
|
||||
"hungtr" = home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = base.modules ++ [
|
||||
modules =
|
||||
base.modules
|
||||
++ [
|
||||
./home.nix
|
||||
];
|
||||
# optionally pass inarguments to module
|
||||
|
@ -118,7 +122,9 @@
|
|||
};
|
||||
"hungtr@bao" = home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = base.modules ++ [
|
||||
modules =
|
||||
base.modules
|
||||
++ [
|
||||
./home.nix
|
||||
nerd_font_module
|
||||
./base/productive_desktop.nix
|
||||
|
@ -145,7 +151,9 @@
|
|||
# Personal darwin, effectively serves as the Darwin edge channel
|
||||
"hungtran" = home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = base.modules ++ [
|
||||
modules =
|
||||
base.modules
|
||||
++ [
|
||||
./home.nix
|
||||
{
|
||||
base.graphics.enable = false;
|
||||
|
@ -177,7 +185,9 @@
|
|||
# Work darwin
|
||||
"htran" = home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = base.modules ++ [
|
||||
modules =
|
||||
base.modules
|
||||
++ [
|
||||
./home.nix
|
||||
./base/productive_desktop.nix
|
||||
./base/darwin-spotlight.nix
|
||||
|
@ -214,8 +224,10 @@
|
|||
./home.nix
|
||||
{
|
||||
base.shells = {
|
||||
shellInitExtra = ''
|
||||
'' + x11_wsl;
|
||||
shellInitExtra =
|
||||
''
|
||||
''
|
||||
+ x11_wsl;
|
||||
};
|
||||
}
|
||||
];
|
||||
|
@ -233,7 +245,9 @@
|
|||
# Personal laptop
|
||||
hwtr = home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = base.modules ++ [
|
||||
modules =
|
||||
base.modules
|
||||
++ [
|
||||
./home.nix
|
||||
./base/graphics.nix
|
||||
{
|
||||
|
|
|
@ -3,18 +3,20 @@
|
|||
# This file represents the base settings for each machine
|
||||
# Additional configurations goes to profiles/<user>
|
||||
# or inlined in flake.nix
|
||||
{ config # Represents the realized final configuration
|
||||
, pkgs # This is by default just ``= import <nixpkgs>{}`
|
||||
, myHome
|
||||
, myLib
|
||||
, option # The options we're given, this might be useful for typesafety?
|
||||
, proj_root
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
inherit (myLib) fromYaml;
|
||||
in
|
||||
{
|
||||
config,
|
||||
# Represents the realized final configuration
|
||||
pkgs,
|
||||
# This is by default just ``= import <nixpkgs>{}`
|
||||
myHome,
|
||||
myLib,
|
||||
option,
|
||||
# The options we're given, this might be useful for typesafety?
|
||||
proj_root,
|
||||
...
|
||||
}: let
|
||||
inherit (myLib) fromYaml;
|
||||
in {
|
||||
imports = [
|
||||
./base/neovim.nix
|
||||
./base/keepass.nix
|
||||
|
@ -24,7 +26,8 @@ in
|
|||
homeDirectory = myHome.homeDirectory;
|
||||
stateVersion = myHome.stateVersion or "22.05";
|
||||
};
|
||||
home.packages = pkgs.lib.unique ([
|
||||
home.packages = pkgs.lib.unique (
|
||||
[
|
||||
# pkgs.ncdu
|
||||
pkgs.rclone # cloud file operations
|
||||
pkgs.htop # system diagnostics in CLI
|
||||
|
@ -46,9 +49,15 @@ in
|
|||
# pkgs.python310.numpy
|
||||
# pkgs.python310Packages.tensorflow
|
||||
# pkgs.python310Packages.scikit-learn
|
||||
] ++ (myHome.packages or [ ]) ++ (if pkgs.system == "x86_64-linux" then [
|
||||
]
|
||||
++ (myHome.packages or [])
|
||||
++ (
|
||||
if pkgs.system == "x86_64-linux"
|
||||
then [
|
||||
pkgs.logseq
|
||||
] else [ ])
|
||||
]
|
||||
else []
|
||||
)
|
||||
);
|
||||
|
||||
## Configs ##
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
flake_input@{ kpcli-py
|
||||
, nixgl
|
||||
, rust-overlay
|
||||
, neovim-nightly-overlay
|
||||
, system
|
||||
, nix-boost
|
||||
, nixpkgs-latest
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
kpcli-py = (final: prev: {
|
||||
flake_input @ {
|
||||
kpcli-py,
|
||||
nixgl,
|
||||
rust-overlay,
|
||||
neovim-nightly-overlay,
|
||||
system,
|
||||
nix-boost,
|
||||
nixpkgs-latest,
|
||||
...
|
||||
}: let
|
||||
kpcli-py = final: prev: {
|
||||
# use python3.9, which works because of cython somehow?
|
||||
kpcli-py = final.poetry2nix.mkPoetryApplication {
|
||||
projectDir = flake_input.kpcli-py;
|
||||
|
@ -37,14 +37,13 @@ let
|
|||
# sha256 = "sha256-Dystt7CBtjpLkgzCsAif8WkkYYeLyh7VMehAtwoDGuM=";
|
||||
# };
|
||||
# });
|
||||
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
rust = (final: prev:
|
||||
let
|
||||
nightlyRustWithExts = exts: final.rust-bin.selectLatestNightlyWith (
|
||||
rust = final: prev: let
|
||||
nightlyRustWithExts = exts:
|
||||
final.rust-bin.selectLatestNightlyWith (
|
||||
toolchain: (toolchain.minimal.override {
|
||||
extensions = exts;
|
||||
})
|
||||
|
@ -52,19 +51,16 @@ let
|
|||
# https://rust-lang.github.io/rustup/concepts/profiles.html
|
||||
rust-default-components = ["rust-docs" "rustfmt" "clippy"];
|
||||
rust-dev-components = rust-default-components ++ ["rust-src" "rust-analyzer" "miri"];
|
||||
in
|
||||
{
|
||||
in {
|
||||
rust4devs = nightlyRustWithExts rust-dev-components;
|
||||
rust4cargo = nightlyRustWithExts [];
|
||||
rust4normi = nightlyRustWithExts rust-default-components;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
vimPlugins = (final: prev: {
|
||||
vimPlugins = final: prev: {
|
||||
inherit (nixpkgs-latest.legacyPackages.${system}) vimPlugins;
|
||||
});
|
||||
in
|
||||
[
|
||||
};
|
||||
in [
|
||||
nix-boost.overlays.default
|
||||
nixgl.overlays.default
|
||||
rust-overlay.overlays.default
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
# main module exporter for different configuration profiles
|
||||
{ pkgs, libs, ... } @ inputs:
|
||||
{
|
||||
pkgs,
|
||||
libs,
|
||||
...
|
||||
} @ inputs: {
|
||||
hwtr = import ./hwtr.nix;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{ pkgs
|
||||
, lib ? pkgs.lib
|
||||
, ...
|
||||
}@flake_import:
|
||||
let
|
||||
{
|
||||
pkgs,
|
||||
lib ? pkgs.lib,
|
||||
...
|
||||
} @ flake_import: let
|
||||
serde = import ./serde {inherit pkgs lib;};
|
||||
recursiveUpdate = lib.recursiveUpdate;
|
||||
in
|
||||
|
|
|
@ -1,31 +1,39 @@
|
|||
# Takes care of serializing and deserializing to some formats
|
||||
# Blame: Pegasust<pegasucksgg@gmail.com>
|
||||
# TODO: Add to* formats from pkgs.formats.*
|
||||
{ pkgs
|
||||
, lib
|
||||
} @ inputs:
|
||||
let
|
||||
yamlToJsonDrv = yamlContent: outputPath: pkgs.callPackage
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
} @ inputs: let
|
||||
yamlToJsonDrv = yamlContent: outputPath:
|
||||
pkgs.callPackage
|
||||
({runCommand}:
|
||||
# runCommand source: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L33
|
||||
runCommand outputPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; }
|
||||
runCommand outputPath
|
||||
{
|
||||
inherit yamlContent;
|
||||
nativeBuildInputs = [pkgs.yq];
|
||||
}
|
||||
# run yq which outputs '.' (no filter) on file at yamlPath
|
||||
# note that $out is passed onto the bash/sh script for execution
|
||||
''
|
||||
echo "$yamlContent" | yq >$out
|
||||
'')
|
||||
{};
|
||||
in
|
||||
{
|
||||
in {
|
||||
# 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
|
||||
fromYaml = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv yamlContent "any_output.json"));
|
||||
fromYamlPath = yamlPath: builtins.fromJSON (
|
||||
fromYamlPath = yamlPath:
|
||||
builtins.fromJSON (
|
||||
builtins.readFile (
|
||||
yamlToJsonDrv
|
||||
(
|
||||
builtins.readFile yamlPath)
|
||||
"any-output.json"));
|
||||
builtins.readFile yamlPath
|
||||
)
|
||||
"any-output.json"
|
||||
)
|
||||
);
|
||||
fromTOML = builtins.fromTOML;
|
||||
fromJSON = builtins.fromJSON;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
# This module aims to be merge (not inject/override) with top-level pkgs to provide
|
||||
# personalized/custom packages
|
||||
{ pkgs
|
||||
, lib
|
||||
, naersk # rust packages
|
||||
, ...
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
naersk,
|
||||
# rust packages
|
||||
...
|
||||
} @ pkgs_input: {
|
||||
# dot-hwtr = import "./dot-hwtr" pkgs_input;
|
||||
cargo-bacon = pkgs.rustPlatform.buildRustPackage rec {
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
naersk.url = "gihub:nix-community/naersk";
|
||||
};
|
||||
outputs = { nixpkgs, rust-overlay, naersk }:
|
||||
let
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
naersk,
|
||||
}: let
|
||||
pkgs = import nixpkgs {overlays = [rust-overlay.overlays.default];};
|
||||
lib = pkgs.lib;
|
||||
in
|
||||
(import ./default.nix { inherit pkgs lib naersk; });
|
||||
in (import ./default.nix {inherit pkgs lib naersk;});
|
||||
}
|
||||
|
|
|
@ -10,10 +10,8 @@ let
|
|||
all = users // systems;
|
||||
# stands for calculus
|
||||
c_ = builtins;
|
||||
in
|
||||
{
|
||||
"system/secrets/s3fs.age".publicKeys = c_.attrValues (all);
|
||||
"system/secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues (all);
|
||||
"system/secrets/_nhitrl.age".publicKeys = c_.attrValues (all);
|
||||
|
||||
in {
|
||||
"system/secrets/s3fs.age".publicKeys = c_.attrValues all;
|
||||
"system/secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues all;
|
||||
"system/secrets/_nhitrl.age".publicKeys = c_.attrValues all;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
{ lib, pkgs, config, modulesPath, specialArgs, ... }:
|
||||
let
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
modulesPath,
|
||||
specialArgs,
|
||||
...
|
||||
}: let
|
||||
hostname = specialArgs.hostname;
|
||||
enableSSH = specialArgs.enableSSH or true;
|
||||
_networking = lib.recursiveUpdate {hostName = hostname;} (specialArgs._networking or {});
|
||||
|
@ -8,11 +14,16 @@ let
|
|||
includeHardware = specialArgs.includeHardware or true;
|
||||
proj_root = builtins.toString ./../..;
|
||||
in
|
||||
with lib;
|
||||
{
|
||||
imports = (if includeHardware then [
|
||||
with lib; {
|
||||
imports =
|
||||
(
|
||||
if includeHardware
|
||||
then [
|
||||
"${proj_root}/hosts/${hostname}/hardware-configuration.nix"
|
||||
] else [ ]) ++ [
|
||||
]
|
||||
else []
|
||||
)
|
||||
++ [
|
||||
"${modulesPath}/profiles/minimal.nix"
|
||||
"${proj_root}/modules/tailscale.sys.nix"
|
||||
"${proj_root}/modules/mosh.sys.nix"
|
||||
|
@ -58,4 +69,3 @@ with lib;
|
|||
pkgs.sysstat # sys diag
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,12 @@
|
|||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, agenix, ... }:
|
||||
let
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
agenix,
|
||||
...
|
||||
}: let
|
||||
lib = nixpkgs.lib;
|
||||
proj_root = ./../..;
|
||||
# TODO: Change respectively to the system or make a nix shell to alias `nix run github:ryantm/agenix -- `
|
||||
|
@ -30,12 +34,13 @@
|
|||
environment.systemPackages = [agenix.defaultPackage.x86_64-linux];
|
||||
}
|
||||
];
|
||||
in
|
||||
{
|
||||
in {
|
||||
# Windows with NixOS WSL
|
||||
nixosConfigurations.Felia = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = base_modules ++ [
|
||||
modules =
|
||||
base_modules
|
||||
++ [
|
||||
./wsl-configuration.nix
|
||||
{
|
||||
system.stateVersion = "22.05";
|
||||
|
@ -52,7 +57,9 @@
|
|||
};
|
||||
nixosConfigurations.lizzi = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = base_modules ++ [
|
||||
modules =
|
||||
base_modules
|
||||
++ [
|
||||
./configuration.nix
|
||||
{
|
||||
system.stateVersion = "22.05";
|
||||
|
@ -62,10 +69,12 @@
|
|||
specialArgs = {
|
||||
hostname = "lizzi";
|
||||
_networking = {
|
||||
interfaces.eth1.ipv4.addresses = [{
|
||||
interfaces.eth1.ipv4.addresses = [
|
||||
{
|
||||
address = "71.0.0.1";
|
||||
prefixLength = 24;
|
||||
}];
|
||||
}
|
||||
];
|
||||
firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [80 443 22];
|
||||
|
@ -112,7 +121,9 @@
|
|||
# Generic machine
|
||||
nixosConfigurations.pixi = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = base_modules ++ [
|
||||
modules =
|
||||
base_modules
|
||||
++ [
|
||||
./configuration.nix
|
||||
{
|
||||
system.stateVersion = "22.05";
|
||||
|
@ -168,7 +179,9 @@
|
|||
};
|
||||
nixosConfigurations.nyx = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = base_modules ++ [
|
||||
modules =
|
||||
base_modules
|
||||
++ [
|
||||
./configuration.nix
|
||||
{
|
||||
system.stateVersion = "22.05";
|
||||
|
@ -178,10 +191,12 @@
|
|||
hostname = "nyx";
|
||||
_networking = {
|
||||
enableIPv6 = false;
|
||||
interfaces.eth1.ipv4.addresses = [{
|
||||
interfaces.eth1.ipv4.addresses = [
|
||||
{
|
||||
address = "71.0.0.2";
|
||||
prefixLength = 24;
|
||||
}];
|
||||
}
|
||||
];
|
||||
firewall.enable = true;
|
||||
useDHCP = false;
|
||||
interfaces.eth0.useDHCP = true;
|
||||
|
@ -196,7 +211,9 @@
|
|||
};
|
||||
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = base_modules ++ [
|
||||
modules =
|
||||
base_modules
|
||||
++ [
|
||||
./configuration.nix
|
||||
{
|
||||
system.stateVersion = "22.05";
|
||||
|
@ -208,7 +225,9 @@
|
|||
};
|
||||
nixosConfigurations.htran-dev = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = base_modules ++ [
|
||||
modules =
|
||||
base_modules
|
||||
++ [
|
||||
./configuration.nix
|
||||
{
|
||||
system.stateVersion = "22.11";
|
||||
|
@ -218,7 +237,10 @@
|
|||
# interface = "ens32";
|
||||
};
|
||||
networking.interfaces.ens32.ipv4.addresses = [
|
||||
{ address = "10.100.200.230"; prefixLength = 24; }
|
||||
{
|
||||
address = "10.100.200.230";
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
|
@ -240,7 +262,9 @@
|
|||
nixosConfigurations.bao = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs.hostname = "bao";
|
||||
modules = base_modules ++ [
|
||||
modules =
|
||||
base_modules
|
||||
++ [
|
||||
./configuration.nix
|
||||
./../../modules/storage.perso.sys.nix
|
||||
./../../modules/kde.sys.nix
|
||||
|
@ -248,8 +272,12 @@
|
|||
./../../modules/pulseaudio.sys.nix
|
||||
./../../modules/opengl.sys.nix
|
||||
./../../modules/nvgpu.sys.nix
|
||||
({ config, pkgs, lib, ... }:
|
||||
{
|
||||
({
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
mod.tailscale.enable = true;
|
||||
# Use UEFI
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
|
@ -23,14 +26,12 @@
|
|||
boot.kernelModules = [];
|
||||
boot.extraModulePackages = [];
|
||||
|
||||
fileSystems."/" =
|
||||
{
|
||||
fileSystems."/" = {
|
||||
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
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
|
|
|
@ -10,4 +10,5 @@
|
|||
)
|
||||
{
|
||||
src = ./.;
|
||||
}).defaultNix
|
||||
})
|
||||
.defaultNix
|
||||
|
|
|
@ -11,9 +11,13 @@
|
|||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, ... }:
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
{
|
||||
|
||||
nixosModules.wsl = {
|
||||
imports = [
|
||||
./modules/build-tarball.nix
|
||||
|
@ -31,16 +35,15 @@
|
|||
./configuration.nix
|
||||
];
|
||||
};
|
||||
|
||||
} //
|
||||
flake-utils.lib.eachSystem
|
||||
}
|
||||
// flake-utils.lib.eachSystem
|
||||
(with flake-utils.lib.system; ["x86_64-linux" "aarch64-linux"])
|
||||
(system:
|
||||
let
|
||||
(
|
||||
system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
in
|
||||
{
|
||||
checks.check-format = pkgs.runCommand "check-format"
|
||||
in {
|
||||
checks.check-format =
|
||||
pkgs.runCommand "check-format"
|
||||
{
|
||||
buildInputs = with pkgs; [nixpkgs-fmt];
|
||||
} ''
|
||||
|
|
|
@ -1,11 +1,23 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
with builtins; with lib;
|
||||
let
|
||||
pkgs2storeContents = l: map (x: { object = x; symlink = "none"; }) l;
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with builtins;
|
||||
with lib; let
|
||||
pkgs2storeContents = l:
|
||||
map
|
||||
(x: {
|
||||
object = x;
|
||||
symlink = "none";
|
||||
})
|
||||
l;
|
||||
|
||||
nixpkgs = lib.cleanSource pkgs.path;
|
||||
|
||||
channelSources = pkgs.runCommand "nixos-${config.system.nixos.version}"
|
||||
channelSources =
|
||||
pkgs.runCommand "nixos-${config.system.nixos.version}"
|
||||
{preferLocalBuild = true;}
|
||||
''
|
||||
mkdir -p $out
|
||||
|
@ -58,10 +70,7 @@ let
|
|||
sed -i 's|import \./default\.nix|import \./nixos-wsl|' ./etc/nixos/configuration.nix
|
||||
''}
|
||||
'';
|
||||
|
||||
in
|
||||
{
|
||||
|
||||
in {
|
||||
options.wsl.tarball = {
|
||||
includeConfig = mkOption {
|
||||
type = types.bool;
|
||||
|
@ -70,7 +79,6 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
|
||||
config = mkIf config.wsl.enable {
|
||||
# These options make no sense without the wsl-distro module anyway
|
||||
|
||||
|
@ -92,6 +100,5 @@ in
|
|||
compressCommand = "gzip";
|
||||
compressionExtension = ".gz";
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
with builtins; with lib; {
|
||||
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with builtins;
|
||||
with lib; {
|
||||
imports = [
|
||||
(mkRenamedOptionModule ["wsl" "docker"] ["wsl" "docker-desktop"])
|
||||
];
|
||||
|
@ -9,12 +14,10 @@ with builtins; with lib; {
|
|||
enable = mkEnableOption "Docker Desktop integration";
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
config = let
|
||||
cfg = config.wsl.docker-desktop;
|
||||
in
|
||||
mkIf (config.wsl.enable && cfg.enable) {
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
docker
|
||||
docker-compose
|
||||
|
@ -35,7 +38,5 @@ with builtins; with lib; {
|
|||
users.groups.docker.members = [
|
||||
config.wsl.defaultUser
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
with builtins; with lib; {
|
||||
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with builtins;
|
||||
with lib; {
|
||||
options.wsl.docker-native = with types; {
|
||||
enable = mkEnableOption "Native Docker integration in NixOS.";
|
||||
|
||||
|
@ -15,8 +20,7 @@ with builtins; with lib; {
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
config = let
|
||||
cfg = config.wsl.docker-native;
|
||||
in
|
||||
mkIf (config.wsl.enable && cfg.enable) {
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
with builtins; with lib; {
|
||||
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with builtins;
|
||||
with lib; {
|
||||
config = mkIf config.wsl.enable (
|
||||
let
|
||||
mkTarball = pkgs.callPackage "${lib.cleanSource pkgs.path}/nixos/lib/make-system-tarball.nix";
|
||||
|
||||
pkgs2storeContents = map (x: { object = x; symlink = "none"; });
|
||||
pkgs2storeContents = map (x: {
|
||||
object = x;
|
||||
symlink = "none";
|
||||
});
|
||||
|
||||
rootfs = let tarball = config.system.build.tarball; in "${tarball}/tarball/${tarball.fileName}.tar${tarball.extension}";
|
||||
|
||||
|
@ -39,25 +47,39 @@ with builtins; with lib; {
|
|||
passwd = pkgs.writeText "passwd" ''
|
||||
root:x:0:0:System administrator:/root:${installer}
|
||||
'';
|
||||
in
|
||||
{
|
||||
|
||||
in {
|
||||
system.build.installer = mkTarball {
|
||||
fileName = "nixos-wsl-installer";
|
||||
compressCommand = "gzip";
|
||||
compressionExtension = ".gz";
|
||||
extraArgs = "--hard-dereference";
|
||||
|
||||
storeContents = with pkgs; pkgs2storeContents [
|
||||
storeContents = with pkgs;
|
||||
pkgs2storeContents [
|
||||
installer
|
||||
];
|
||||
|
||||
contents = [
|
||||
{ source = config.environment.etc."wsl.conf".source; target = "/etc/wsl.conf"; }
|
||||
{ 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"; }
|
||||
{
|
||||
source = config.environment.etc."wsl.conf".source;
|
||||
target = "/etc/wsl.conf";
|
||||
}
|
||||
{
|
||||
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" ''
|
||||
|
@ -66,8 +88,6 @@ with builtins; with lib; {
|
|||
ln -s /init bin/wslpath
|
||||
'';
|
||||
};
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
{ lib, pkgs, config, ... }:
|
||||
|
||||
with builtins; with lib;
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with builtins;
|
||||
with lib; {
|
||||
imports = [
|
||||
(mkRenamedOptionModule ["wsl" "compatibility" "interopPreserveArgvZero"] ["wsl" "interop" "preserveArgvZero"])
|
||||
];
|
||||
|
@ -32,15 +36,12 @@ with builtins; with lib;
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
config = let
|
||||
cfg = config.wsl.interop;
|
||||
in
|
||||
mkIf config.wsl.enable {
|
||||
|
||||
boot.binfmt.registrations = mkIf cfg.register {
|
||||
WSLInterop =
|
||||
let
|
||||
WSLInterop = let
|
||||
compat = cfg.preserveArgvZero;
|
||||
|
||||
# WSL Preview 0.58 and up registers the /init binfmt interp for Windows executable
|
||||
|
@ -61,12 +62,17 @@ with builtins; with lib;
|
|||
'';
|
||||
|
||||
# use the autodetect hack if unset, otherwise call /init directly
|
||||
interpreter = if compat == null then compatWrapper else "/init";
|
||||
interpreter =
|
||||
if compat == null
|
||||
then compatWrapper
|
||||
else "/init";
|
||||
|
||||
# enable for the wrapper and autodetect hack
|
||||
preserveArgvZero = if compat == false then false else true;
|
||||
in
|
||||
{
|
||||
preserveArgvZero =
|
||||
if compat == false
|
||||
then false
|
||||
else true;
|
||||
in {
|
||||
magicOrExtension = "MZ";
|
||||
fixBinary = true;
|
||||
wrapInterpreterInShell = false;
|
||||
|
@ -77,12 +83,9 @@ with builtins; with lib;
|
|||
# Include Windows %PATH% in Linux $PATH.
|
||||
environment.extraInit = mkIf cfg.includePath ''PATH="$PATH:$WSLPATH"'';
|
||||
|
||||
warnings =
|
||||
let
|
||||
warnings = let
|
||||
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";
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
{ lib, pkgs, config, ... }:
|
||||
|
||||
with builtins; with lib;
|
||||
{
|
||||
options.wsl = with types;
|
||||
let
|
||||
coercedToStr = coercedTo (oneOf [ bool path int ]) (toString) str;
|
||||
in
|
||||
{
|
||||
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;
|
||||
|
@ -30,13 +32,15 @@ with builtins; with lib;
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
config = let
|
||||
cfg = config.wsl;
|
||||
syschdemd = import ../syschdemd.nix { inherit lib pkgs config; inherit (cfg) automountPath defaultUser; defaultUserHome = config.users.users.${cfg.defaultUser}.home; };
|
||||
syschdemd = import ../syschdemd.nix {
|
||||
inherit lib pkgs config;
|
||||
inherit (cfg) automountPath defaultUser;
|
||||
defaultUserHome = config.users.users.${cfg.defaultUser}.home;
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
|
||||
wsl.wslConf = {
|
||||
automount = {
|
||||
enabled = true;
|
||||
|
@ -57,7 +61,6 @@ with builtins; with lib;
|
|||
hardware.opengl.enable = true; # Enable GPU acceleration
|
||||
|
||||
environment = {
|
||||
|
||||
etc = {
|
||||
"wsl.conf".text = generators.toINI {} cfg.wslConf;
|
||||
|
||||
|
@ -134,6 +137,6 @@ with builtins; with lib;
|
|||
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";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{ lib
|
||||
, pkgs
|
||||
, config
|
||||
, automountPath
|
||||
, defaultUser
|
||||
, defaultUserHome ? "/home/${defaultUser}"
|
||||
, ...
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
automountPath,
|
||||
defaultUser,
|
||||
defaultUserHome ? "/home/${defaultUser}",
|
||||
...
|
||||
}:
|
||||
|
||||
pkgs.substituteAll {
|
||||
name = "syschdemd";
|
||||
src = ./syschdemd.sh;
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [];
|
||||
|
||||
boot.initrd.availableKernelModules = [];
|
||||
|
@ -43,20 +47,17 @@
|
|||
# fsType = "drvfs";
|
||||
# };
|
||||
|
||||
fileSystems."/mnt/c" =
|
||||
{
|
||||
fileSystems."/mnt/c" = {
|
||||
device = "C:";
|
||||
fsType = "drvfs";
|
||||
};
|
||||
|
||||
fileSystems."/mnt/d" =
|
||||
{
|
||||
fileSystems."/mnt/d" = {
|
||||
device = "D:";
|
||||
fsType = "drvfs";
|
||||
};
|
||||
|
||||
fileSystems."/mnt/f" =
|
||||
{
|
||||
fileSystems."/mnt/f" = {
|
||||
device = "F:";
|
||||
fsType = "drvfs";
|
||||
};
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
|
@ -23,14 +26,12 @@
|
|||
boot.kernelModules = [];
|
||||
boot.extraModulePackages = [];
|
||||
|
||||
fileSystems."/" =
|
||||
{
|
||||
fileSystems."/" = {
|
||||
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
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
|
@ -23,14 +26,12 @@
|
|||
boot.kernelModules = [];
|
||||
boot.extraModulePackages = [];
|
||||
|
||||
fileSystems."/" =
|
||||
{
|
||||
fileSystems."/" = {
|
||||
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
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
|
@ -35,8 +38,7 @@
|
|||
};
|
||||
};
|
||||
|
||||
swapDevices =
|
||||
[{ device = "/dev/sdb"; }];
|
||||
swapDevices = [{device = "/dev/sdb";}];
|
||||
|
||||
# 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
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
|
@ -23,14 +26,12 @@
|
|||
boot.loader.grub.forceInstall = true;
|
||||
boot.loader.grub.device = "nodev";
|
||||
boot.loader.timeout = 10;
|
||||
fileSystems."/" =
|
||||
{
|
||||
fileSystems."/" = {
|
||||
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
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
{lib, ...}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
with lib; let
|
||||
nixos-wsl = import ./nixos-wsl;
|
||||
in
|
||||
{
|
||||
in {
|
||||
imports = [
|
||||
./configuration.nix
|
||||
nixos-wsl.nixosModules.wsl
|
||||
|
@ -21,9 +18,7 @@ in
|
|||
|
||||
# Enable integration with Docker Desktop (needs to be installed)
|
||||
docker-desktop.enable = true;
|
||||
|
||||
};
|
||||
# users.users.<defaultUser>.uid = 1000;
|
||||
# networking.hostName = "nixos";
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{inputs, cell}: let
|
||||
{
|
||||
inputs,
|
||||
cell,
|
||||
}: let
|
||||
inherit (inputs) std nixpkgs;
|
||||
|
||||
in {
|
||||
default = std.lib.dev.mkShell {
|
||||
name = "default";
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
inputs,
|
||||
cell,
|
||||
}: let
|
||||
in {}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
inputs,
|
||||
cell,
|
||||
}: {}
|
|
@ -1,11 +1,14 @@
|
|||
# This is an interface for home-profiles and should not contain opinionated
|
||||
# configurations. It should provide alternative configurations, aggregates
|
||||
# or new configurations
|
||||
_imports@{inputs, cell}: let
|
||||
_imports@{ inputs, cell }:
|
||||
let
|
||||
namespace = "repo";
|
||||
imports = _imports // { inherit namespace; };
|
||||
in {
|
||||
git = { config , lib , ... }: let
|
||||
in
|
||||
{
|
||||
git = { config, lib, ... }:
|
||||
let
|
||||
cfg = config."${namespace}".git;
|
||||
baseAliases = {
|
||||
a = "add";
|
||||
|
@ -20,7 +23,8 @@ in {
|
|||
};
|
||||
default-user = "Pegasust";
|
||||
default-email = "pegasucksgg@gmail.com";
|
||||
in {
|
||||
in
|
||||
{
|
||||
options."${namespace}".git = {
|
||||
aliases = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
|
@ -87,10 +91,12 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
alacritty = {config, lib}: let
|
||||
alacritty = { config, lib }:
|
||||
let
|
||||
inherit (inputs.cells.repo.lib) fromYAML;
|
||||
cfg = config."${namespace}".alacritty;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options."${namespace}".alacritty = {
|
||||
font.family = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.singleLineStr;
|
||||
|
@ -102,7 +108,7 @@ in {
|
|||
};
|
||||
font.size = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.number;
|
||||
default = null;
|
||||
default = 11.0;
|
||||
description = ''
|
||||
The default font size for Alacritty. This is probably measured in px.
|
||||
'';
|
||||
|
@ -116,7 +122,7 @@ in {
|
|||
'';
|
||||
example = true;
|
||||
};
|
||||
config-file = lib.mkOption {
|
||||
config-path = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "Path to alacritty yaml";
|
||||
default = null;
|
||||
|
@ -125,21 +131,25 @@ in {
|
|||
};
|
||||
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;
|
||||
settings =
|
||||
let
|
||||
;
|
||||
actualConfig =
|
||||
if cfg.config-path != null then fromYAML (builtins.readFile cfg.config-path) else { };
|
||||
in
|
||||
lib.recursiveUpdate actualConfig {
|
||||
font.normal.family = lib.mkIf (font.family != null) font.family;
|
||||
font.size = lib.mkIf (font.size != null) font.size;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# TODO: chromium is not really supported on darwin
|
||||
private_chromium = { config, pkgs, lib, ... }: let
|
||||
private_chromium = { config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config."${namespace}".private_chromium;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options."${namespace}".private_chromium = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
{inputs, cell, namespace}: { pkgs, config, lib, ... }:
|
||||
let
|
||||
{
|
||||
inputs,
|
||||
cell,
|
||||
namespace,
|
||||
}: {
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config."${namespace}".graphics;
|
||||
cfgEnable = cfg.enable or (cfg.useNixGL.defaultPackage != null);
|
||||
types = lib.types;
|
||||
in
|
||||
{
|
||||
in {
|
||||
imports = [./shells.nix];
|
||||
options."${namespace}".nixgl = {
|
||||
enable = lib.mkEnableOption "nixgl";
|
||||
|
|
|
@ -1,11 +1,23 @@
|
|||
_imports@{inputs, cell}: let
|
||||
# This creates a layer that is specific to some profiles, but may require
|
||||
# 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";
|
||||
imports = _imports // {inherit namespace;};
|
||||
in {
|
||||
neovim = import ./neovim.nix imports;
|
||||
nerd_font_module = {config, pkgs, ...}: {
|
||||
nerd_font_module = {
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
import inputs.cells."${namespace}"
|
||||
import
|
||||
inputs.cells."${namespace}"
|
||||
];
|
||||
fonts.fontconfig.enable = true;
|
||||
home.packages = [
|
||||
|
@ -32,7 +44,13 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
ssh = {config, lib, ...}: let cfg = config."${namespace}".ssh; in {
|
||||
ssh = {
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config."${namespace}".ssh;
|
||||
in {
|
||||
options."${namespace}".ssh.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
|
@ -48,13 +66,79 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
alacritty = {config, lib,...}: let cfg = config."${namespace}".alacritty; in {
|
||||
alacritty = {
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config."${namespace}".alacritty;
|
||||
in {
|
||||
imports = [
|
||||
import "${inputs.cells.repo.home-modules.alacritty}"
|
||||
import
|
||||
"${inputs.cells.repo.home-modules.alacritty}"
|
||||
];
|
||||
configs."${namespace}".alacritty = {
|
||||
enable = true;
|
||||
config-file = "${inputs.self}//native-configs/alacritty/alacritty.yml";
|
||||
config-path = "${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"];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,22 +2,32 @@
|
|||
#
|
||||
# One thing to consider, though, /nix/store of `nix-shell` or `nix-develop`
|
||||
# might be different from `home-manager`'s (~/.nix_profile/bin/jq)
|
||||
{inputs, cell, namespace}: { pkgs, lib, config, ... }:
|
||||
let
|
||||
{
|
||||
inputs,
|
||||
cell,
|
||||
namespace,
|
||||
}: {
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
# NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace
|
||||
# and is added to the path after wrapping.
|
||||
# check: nix repl `homeConfigurations.hungtr.config.programs.neovim.finalPackage.buildCommand`
|
||||
# see: :/--suffix.*PATH
|
||||
# there should be mentions of additional packages
|
||||
my_neovim = pkgs.neovim-unwrapped;
|
||||
rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith
|
||||
rust_pkgs =
|
||||
pkgs.rust-bin.selectLatestNightlyWith
|
||||
(
|
||||
toolchain:
|
||||
toolchain.default.override {
|
||||
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
|
||||
|
@ -48,16 +58,16 @@ let
|
|||
# pkgs.rust-analyzer
|
||||
# rust_pkgs
|
||||
# pkgs.evcxr # Rust REPL for Conjure!
|
||||
] ++ lib.optionals (pkgs.stdenv.isDarwin) (
|
||||
]
|
||||
++ lib.optionals (pkgs.stdenv.isDarwin) (
|
||||
let
|
||||
inherit (pkgs.darwin.apple_sdk.frameworks) System CoreFoundation; in
|
||||
[
|
||||
inherit (pkgs.darwin.apple_sdk.frameworks) System CoreFoundation;
|
||||
in [
|
||||
System
|
||||
CoreFoundation
|
||||
]
|
||||
);
|
||||
in
|
||||
{
|
||||
in {
|
||||
options.base.neovim = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
|
@ -77,30 +87,25 @@ in
|
|||
withNodeJs = true;
|
||||
# NOTE: this adds path to the wrapped version of neovim
|
||||
extraPackages = nvim_pkgs;
|
||||
extraLuaConfig = (builtins.readFile "${inputs.self}/native_configs/neovim/init.lua");
|
||||
plugins = (let inherit (pkgs.vimPlugins)
|
||||
extraLuaConfig = builtins.readFile "${inputs.self}/native_configs/neovim/init.lua";
|
||||
plugins = let
|
||||
inherit
|
||||
(pkgs.vimPlugins)
|
||||
plenary-nvim
|
||||
|
||||
nvim-treesitter
|
||||
nvim-treesitter-textobjects
|
||||
nvim-treesitter-context
|
||||
|
||||
telescope-fzf-native-nvim
|
||||
telescope-file-browser-nvim
|
||||
telescope-nvim
|
||||
|
||||
nvim-lspconfig
|
||||
|
||||
gruvbox-community
|
||||
|
||||
neodev-nvim
|
||||
|
||||
cmp-nvim-lsp
|
||||
cmp-path
|
||||
cmp-buffer
|
||||
cmp-cmdline
|
||||
nvim-cmp
|
||||
|
||||
lspkind-nvim
|
||||
nvim-autopairs
|
||||
nvim-ts-autotag
|
||||
|
@ -110,7 +115,6 @@ in
|
|||
luasnip
|
||||
fidget-nvim
|
||||
rust-tools-nvim
|
||||
|
||||
cmp_luasnip
|
||||
gitsigns-nvim
|
||||
indent-blankline-nvim
|
||||
|
@ -129,8 +133,8 @@ in
|
|||
vim-dispatch-neovim
|
||||
vim-fugitive
|
||||
vim-jack-in
|
||||
|
||||
; in [
|
||||
;
|
||||
in [
|
||||
plenary-nvim
|
||||
nvim-treesitter.withAllGrammars
|
||||
nvim-treesitter-textobjects
|
||||
|
@ -174,7 +178,7 @@ in
|
|||
vim-dispatch-neovim
|
||||
vim-fugitive
|
||||
vim-jack-in
|
||||
]);
|
||||
];
|
||||
};
|
||||
# home.packages = nvim_pkgs;
|
||||
};
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
{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 = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
|
@ -47,9 +51,8 @@ in
|
|||
};
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
# extraConfigBeforePlugin = builtins.readFile "${proj_root.config.path}/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");
|
||||
extraConfig = builtins.readFile "${innputs.self}/native_configs/tmux/tmux.conf";
|
||||
};
|
||||
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 '
|
||||
|
@ -64,14 +67,15 @@ in
|
|||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
settings = let
|
||||
native = builtins.fromTOML (builtins.readFile "${proj_root.config.path}/starship/starship.toml");
|
||||
patch-nix = pkgs.lib.recursiveUpdate native ({
|
||||
native = builtins.fromTOML (builtins.readFile "${inputs.self}/native_configs/starship/starship.toml");
|
||||
patch-nix = pkgs.lib.recursiveUpdate native {
|
||||
c.commands = [
|
||||
["nix" "run" "nixpkgs#clang" "--" "--version"]
|
||||
["nix" "run" "nixpkgs#gcc" "--" "--version"]
|
||||
];
|
||||
});
|
||||
in patch-nix;
|
||||
};
|
||||
in
|
||||
patch-nix;
|
||||
};
|
||||
# Fuzzy finder. `fzf` for TUI, `fzf -f '<fuzzy query>'` for UNIX piping
|
||||
programs.fzf.enable = true;
|
||||
|
@ -84,10 +88,12 @@ in
|
|||
enable = true;
|
||||
enableCompletion = true;
|
||||
enableAutosuggestions = true;
|
||||
shellAliases = {
|
||||
shellAliases =
|
||||
{
|
||||
nix-rebuild = "sudo nixos-rebuild switch";
|
||||
hm-switch = "home-manager switch --flake";
|
||||
} // (cfg.shellAliases or { });
|
||||
}
|
||||
// (cfg.shellAliases or {});
|
||||
history = {
|
||||
size = 10000;
|
||||
path = "${config.xdg.dataHome}/zsh/history";
|
||||
|
@ -112,10 +118,11 @@ in
|
|||
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 :)
|
||||
};
|
||||
initExtra = (cfg.shellInitExtra or "") + ''
|
||||
initExtra =
|
||||
(cfg.shellInitExtra or "")
|
||||
+ ''
|
||||
source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
|
||||
'';
|
||||
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,18 +1,22 @@
|
|||
{inputs, cell}: let
|
||||
{ inputs, cell }:
|
||||
let
|
||||
namespace = "repo";
|
||||
|
||||
|
||||
yamlToJsonDrv = pkgs: yamlContent: outputPath: (pkgs.runCommand
|
||||
outputPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; }
|
||||
outputPath
|
||||
{ inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; }
|
||||
# run yq which outputs '.' (no filter) on file at yamlPath
|
||||
# note that $out is passed onto the bash/sh script for execution
|
||||
''
|
||||
echo "$yamlContent" | yq >$out
|
||||
'')
|
||||
{ });
|
||||
in {
|
||||
in
|
||||
{
|
||||
fromYAML = yamlContent: bulitins.fromJSON (builtins.readFile (yamlToJsonDrv inputs.nixpkgs yamlContent "fromYaml.json"));
|
||||
|
||||
# NOTE: Deprecate
|
||||
# ctor
|
||||
opt-some = a: [ a ];
|
||||
opt-none = [ ];
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
{inputs, cell}: {
|
||||
{
|
||||
inputs,
|
||||
cell,
|
||||
}: {
|
||||
htran = inputs.cells.dotfiles.devshells.default;
|
||||
hungtran = inputs.cells.dotfiles.devshells.default;
|
||||
}
|
||||
|
|
|
@ -4,22 +4,26 @@
|
|||
# calls the flake's 'outputs' function. It then returns an attrset
|
||||
# containing 'defaultNix' (to be used in 'default.nix'), 'shellNix'
|
||||
# (to be used in 'shell.nix').
|
||||
|
||||
{ src, system ? builtins.currentSystem or "unknown-system" }:
|
||||
|
||||
let
|
||||
|
||||
{
|
||||
src,
|
||||
system ? builtins.currentSystem or "unknown-system",
|
||||
}: let
|
||||
lockFilePath = src + "/flake.lock";
|
||||
|
||||
lockFile = builtins.fromJSON (builtins.readFile lockFilePath);
|
||||
|
||||
fetchTree =
|
||||
info:
|
||||
if info.type == "github" then
|
||||
{ outPath =
|
||||
fetchTree = info:
|
||||
if info.type == "github"
|
||||
then {
|
||||
outPath =
|
||||
fetchTarball
|
||||
({ url = "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}"; }
|
||||
// (if info ? narHash then { sha256 = info.narHash; } else {})
|
||||
(
|
||||
{url = "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}";}
|
||||
// (
|
||||
if info ? narHash
|
||||
then {sha256 = info.narHash;}
|
||||
else {}
|
||||
)
|
||||
);
|
||||
rev = info.rev;
|
||||
shortRev = builtins.substring 0 7 info.rev;
|
||||
|
@ -27,43 +31,76 @@ let
|
|||
lastModifiedDate = formatSecondsSinceEpoch info.lastModified;
|
||||
narHash = info.narHash;
|
||||
}
|
||||
else if info.type == "git" then
|
||||
{ outPath =
|
||||
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 {})
|
||||
(
|
||||
{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;
|
||||
lastModifiedDate = formatSecondsSinceEpoch info.lastModified;
|
||||
narHash = info.narHash;
|
||||
} // (if info ? rev then {
|
||||
}
|
||||
// (
|
||||
if info ? rev
|
||||
then {
|
||||
rev = info.rev;
|
||||
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 != "/"
|
||||
}
|
||||
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
|
||||
};
|
||||
narHash = info.narHash;
|
||||
}
|
||||
else if info.type == "tarball" then
|
||||
{ outPath =
|
||||
fetchTarball
|
||||
({ inherit (info) url; }
|
||||
// (if info ? narHash then { sha256 = info.narHash; } else {})
|
||||
);
|
||||
}
|
||||
else if info.type == "gitlab" then
|
||||
{ inherit (info) rev narHash lastModified;
|
||||
else if info.type == "tarball"
|
||||
then {
|
||||
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 {})
|
||||
(
|
||||
{inherit (info) url;}
|
||||
// (
|
||||
if info ? narHash
|
||||
then {sha256 = info.narHash;}
|
||||
else {}
|
||||
)
|
||||
);
|
||||
}
|
||||
else if info.type == "gitlab"
|
||||
then {
|
||||
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;
|
||||
}
|
||||
|
@ -71,46 +108,55 @@ let
|
|||
# FIXME: add Mercurial, tarball inputs.
|
||||
throw "flake input has unsupported input type '${info.type}'";
|
||||
|
||||
callFlake4 = flakeSrc: locks:
|
||||
let
|
||||
callFlake4 = flakeSrc: locks: let
|
||||
flake = import (flakeSrc + "/flake.nix");
|
||||
|
||||
inputs = builtins.mapAttrs (n: v:
|
||||
inputs =
|
||||
builtins.mapAttrs
|
||||
(n: v:
|
||||
if v.flake or true
|
||||
then callFlake4 (fetchTree (v.locked // v.info)) v.inputs
|
||||
else fetchTree (v.locked // v.info)) locks;
|
||||
else fetchTree (v.locked // v.info))
|
||||
locks;
|
||||
|
||||
outputs = flakeSrc // (flake.outputs (inputs // {self = outputs;}));
|
||||
in
|
||||
assert flake.edition == 201909;
|
||||
outputs;
|
||||
assert flake.edition == 201909; outputs;
|
||||
|
||||
callLocklessFlake = flakeSrc:
|
||||
let
|
||||
callLocklessFlake = flakeSrc: let
|
||||
flake = import (flakeSrc + "/flake.nix");
|
||||
outputs = flakeSrc // (flake.outputs ({ self = outputs; }));
|
||||
in outputs;
|
||||
outputs = flakeSrc // (flake.outputs {self = outputs;});
|
||||
in
|
||||
outputs;
|
||||
|
||||
rootSrc = let
|
||||
# Try to clean the source tree by using fetchGit, if this source
|
||||
# tree is a valid git repository.
|
||||
tryFetchGit = src:
|
||||
if isGit && !isShallow
|
||||
then
|
||||
let res = builtins.fetchGit src;
|
||||
in if res.rev == "0000000000000000000000000000000000000000" then removeAttrs res ["rev" "shortRev"] else res
|
||||
then let
|
||||
res = builtins.fetchGit src;
|
||||
in
|
||||
if res.rev == "0000000000000000000000000000000000000000"
|
||||
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
|
||||
isGit = builtins.pathExists (src + "/.git");
|
||||
isShallow = builtins.pathExists (src + "/.git/shallow");
|
||||
|
||||
in
|
||||
{ lastModified = 0; lastModifiedDate = formatSecondsSinceEpoch 0; }
|
||||
// (if src ? outPath then src else tryFetchGit src);
|
||||
{
|
||||
lastModified = 0;
|
||||
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.
|
||||
formatSecondsSinceEpoch = t:
|
||||
let
|
||||
formatSecondsSinceEpoch = t: let
|
||||
rem = x: y: x - x / y * y;
|
||||
days = t / 86400;
|
||||
secondsInDay = rem t 86400;
|
||||
|
@ -120,33 +166,65 @@ let
|
|||
|
||||
# Courtesy of https://stackoverflow.com/a/32158604.
|
||||
z = days + 719468;
|
||||
era = (if z >= 0 then z else z - 146096) / 146097;
|
||||
era =
|
||||
(
|
||||
if z >= 0
|
||||
then z
|
||||
else z - 146096
|
||||
)
|
||||
/ 146097;
|
||||
doe = z - era * 146097;
|
||||
yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
|
||||
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);
|
||||
m =
|
||||
mp
|
||||
+ (
|
||||
if mp < 10
|
||||
then 3
|
||||
else -9
|
||||
);
|
||||
y' =
|
||||
y
|
||||
+ (
|
||||
if m <= 2
|
||||
then 1
|
||||
else 0
|
||||
);
|
||||
|
||||
pad = s: if builtins.stringLength s < 2 then "0" + s else s;
|
||||
pad = s:
|
||||
if builtins.stringLength s < 2
|
||||
then "0" + s
|
||||
else s;
|
||||
in "${toString y'}${pad (toString m)}${pad (toString d)}${pad (toString hours)}${pad (toString minutes)}${pad (toString seconds)}";
|
||||
|
||||
allNodes =
|
||||
builtins.mapAttrs
|
||||
(key: node:
|
||||
let
|
||||
(
|
||||
key: node: let
|
||||
sourceInfo =
|
||||
if key == lockFile.root
|
||||
then rootSrc
|
||||
else fetchTree (node.info or {} // removeAttrs node.locked ["dir"]);
|
||||
|
||||
subdir = if key == lockFile.root then "" else node.locked.dir or "";
|
||||
subdir =
|
||||
if key == lockFile.root
|
||||
then ""
|
||||
else node.locked.dir or "";
|
||||
|
||||
flake = import (sourceInfo + (if subdir != "" then "/" else "") + subdir + "/flake.nix");
|
||||
flake = import (sourceInfo
|
||||
+ (
|
||||
if subdir != ""
|
||||
then "/"
|
||||
else ""
|
||||
)
|
||||
+ subdir
|
||||
+ "/flake.nix");
|
||||
|
||||
inputs = builtins.mapAttrs
|
||||
inputs =
|
||||
builtins.mapAttrs
|
||||
(inputName: inputSpec: allNodes.${resolveInput inputSpec})
|
||||
(node.inputs or {});
|
||||
|
||||
|
@ -171,13 +249,18 @@ let
|
|||
|
||||
outputs = flake.outputs (inputs // {self = result;});
|
||||
|
||||
result = outputs // sourceInfo // { inherit inputs; inherit outputs; inherit sourceInfo; };
|
||||
result =
|
||||
outputs
|
||||
// sourceInfo
|
||||
// {
|
||||
inherit inputs;
|
||||
inherit outputs;
|
||||
inherit sourceInfo;
|
||||
};
|
||||
in
|
||||
if node.flake or true then
|
||||
assert builtins.isFunction flake.outputs;
|
||||
result
|
||||
else
|
||||
sourceInfo
|
||||
if node.flake or true
|
||||
then assert builtins.isFunction flake.outputs; result
|
||||
else sourceInfo
|
||||
)
|
||||
lockFile.nodes;
|
||||
|
||||
|
@ -189,16 +272,30 @@ let
|
|||
else if lockFile.version >= 5 && lockFile.version <= 7
|
||||
then allNodes.${lockFile.root}
|
||||
else throw "lock file '${lockFilePath}' has unsupported version ${toString lockFile.version}";
|
||||
|
||||
in
|
||||
rec {
|
||||
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 {});
|
||||
// (
|
||||
if result ? defaultPackage.${system}
|
||||
then {default = result.defaultPackage.${system};}
|
||||
else {}
|
||||
)
|
||||
// (
|
||||
if result ? packages.${system}.default
|
||||
then {default = result.packages.${system}.default;}
|
||||
else {}
|
||||
);
|
||||
|
||||
shellNix =
|
||||
defaultNix
|
||||
// (if result ? devShell.${system} then { default = result.devShell.${system}; } else {})
|
||||
// (if result ? devShells.${system}.default then { default = result.devShells.${system}.default; } else {});
|
||||
// (
|
||||
if result ? devShell.${system}
|
||||
then {default = result.devShell.${system};}
|
||||
else {}
|
||||
)
|
||||
// (
|
||||
if result ? devShells.${system}.default
|
||||
then {default = result.devShells.${system}.default;}
|
||||
else {}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,19 +6,19 @@ let
|
|||
nvidiaHash = "edd415acf2f75a659e0f3b4f27c1fab770cf21614e84a18152d94f0d004a758e";
|
||||
});
|
||||
|
||||
versionFile440 = (pkgs.callPackage ./nixGL.nix {
|
||||
versionFile440 = pkgs.callPackage ./nixGL.nix {
|
||||
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
|
||||
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" ''
|
||||
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)
|
||||
'';
|
||||
});
|
||||
};
|
||||
in
|
||||
(with pure; [nixGLIntel nixVulkanNvidia nixGLNvidia nixVulkanIntel])
|
||||
++ (with versionFile440.auto; [nixGLNvidia nixGLDefault nixVulkanNvidia])
|
||||
|
|
|
@ -1,26 +1,27 @@
|
|||
{
|
||||
## Nvidia informations.
|
||||
# Version of the system kernel module. Let it to null to enable auto-detection.
|
||||
nvidiaVersion ? null
|
||||
, # Hash of the Nvidia driver .run file. null is fine, but fixing a value here
|
||||
nvidiaVersion ? null,
|
||||
# Hash of the Nvidia driver .run file. null is fine, but fixing a value here
|
||||
# will be more reproducible and more efficient.
|
||||
nvidiaHash ? null
|
||||
, # Alternatively, you can pass a path that points to a nvidia version file
|
||||
nvidiaHash ? null,
|
||||
# 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
|
||||
# /proc/driver/nvidia/version. Nix doesn't like zero-sized files (see
|
||||
# https://github.com/NixOS/nix/issues/3539 ).
|
||||
nvidiaVersionFile ? null
|
||||
, # Enable 32 bits driver
|
||||
nvidiaVersionFile ? null,
|
||||
# Enable 32 bits driver
|
||||
# This is on by default, you can switch it to off if you want to reduce a
|
||||
# bit the size of nixGL closure.
|
||||
enable32bits ? true
|
||||
, # Make sure to enable config.allowUnfree to the instance of nixpkgs to be
|
||||
enable32bits ? true,
|
||||
# Make sure to enable config.allowUnfree to the instance of nixpkgs to be
|
||||
# able to access the nvidia drivers.
|
||||
pkgs ? import <nixpkgs> {
|
||||
pkgs ?
|
||||
import <nixpkgs> {
|
||||
config = {allowUnfree = true;};
|
||||
}
|
||||
, # Enable all Intel specific extensions which only works on x86_64
|
||||
enableIntelX86Extensions ? true
|
||||
},
|
||||
# Enable all Intel specific extensions which only works on x86_64
|
||||
enableIntelX86Extensions ? true,
|
||||
}:
|
||||
pkgs.callPackage ./nixGL.nix ({
|
||||
inherit
|
||||
|
@ -29,8 +30,12 @@ pkgs.callPackage ./nixGL.nix ({
|
|||
nvidiaHash
|
||||
enable32bits
|
||||
;
|
||||
} // (if enableIntelX86Extensions then { }
|
||||
}
|
||||
// (
|
||||
if enableIntelX86Extensions
|
||||
then {}
|
||||
else {
|
||||
intel-media-driver = null;
|
||||
vaapiIntel = null;
|
||||
}))
|
||||
}
|
||||
))
|
||||
|
|
|
@ -4,9 +4,12 @@
|
|||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
inputs.nixpkgs.url = "github:nixos/nixpkgs";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
(flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
(flake-utils.lib.eachDefaultSystem (system: let
|
||||
isIntelX86Platform = system == "x86_64-linux";
|
||||
nix_pkgs = import nixpkgs {inherit system;};
|
||||
pkgs = import ./default.nix {
|
||||
|
@ -14,9 +17,7 @@
|
|||
enable32bits = isIntelX86Platform;
|
||||
enableIntelX86Extensions = isIntelX86Platform;
|
||||
};
|
||||
in
|
||||
rec {
|
||||
|
||||
in rec {
|
||||
packages = {
|
||||
# makes it easy to use "nix run nixGL --impure -- program"
|
||||
default = pkgs.auto.nixGLDefault;
|
||||
|
@ -27,16 +28,16 @@
|
|||
nixGLIntel = pkgs.nixGLIntel;
|
||||
nixVulkanNvidia = pkgs.auto.nixVulkanNvidia;
|
||||
nixVulkanIntel = pkgs.nixVulkanIntel;
|
||||
|
||||
};
|
||||
|
||||
# deprecated attributes for retro compatibility
|
||||
defaultPackage = packages;
|
||||
})) // rec {
|
||||
}))
|
||||
// rec {
|
||||
# deprecated attributes for retro compatibility
|
||||
overlay = overlays.default;
|
||||
overlays.default = final: _:
|
||||
let isIntelX86Platform = final.system == "x86_64-linux";
|
||||
overlays.default = final: _: let
|
||||
isIntelX86Platform = final.system == "x86_64-linux";
|
||||
in {
|
||||
nixgl = import ./default.nix {
|
||||
pkgs = final;
|
||||
|
|
|
@ -1,45 +1,46 @@
|
|||
{
|
||||
# # Nvidia informations.
|
||||
# Version of the system kernel module. Let it to null to enable auto-detection.
|
||||
nvidiaVersion ? null
|
||||
, # Hash of the Nvidia driver .run file. null is fine, but fixing a value here
|
||||
nvidiaVersion ? null,
|
||||
# Hash of the Nvidia driver .run file. null is fine, but fixing a value here
|
||||
# will be more reproducible and more efficient.
|
||||
nvidiaHash ? null
|
||||
, # Alternatively, you can pass a path that points to a nvidia version file
|
||||
nvidiaHash ? null,
|
||||
# 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
|
||||
# /proc/driver/nvidia/version. Nix doesn't like zero-sized files (see
|
||||
# https://github.com/NixOS/nix/issues/3539 ).
|
||||
nvidiaVersionFile ? null
|
||||
, # Enable 32 bits driver
|
||||
nvidiaVersionFile ? null,
|
||||
# Enable 32 bits driver
|
||||
# This is one by default, you can switch it to off if you want to reduce a
|
||||
# bit the size of nixGL closure.
|
||||
enable32bits ? true
|
||||
, writeTextFile
|
||||
, shellcheck
|
||||
, pcre
|
||||
, runCommand
|
||||
, linuxPackages
|
||||
, fetchurl
|
||||
, lib
|
||||
, runtimeShell
|
||||
, bumblebee
|
||||
, libglvnd
|
||||
, vulkan-validation-layers
|
||||
, mesa
|
||||
, libvdpau-va-gl
|
||||
, intel-media-driver
|
||||
, vaapiIntel
|
||||
, pkgsi686Linux
|
||||
, driversi686Linux
|
||||
, zlib
|
||||
, libdrm
|
||||
, xorg
|
||||
, wayland
|
||||
, gcc
|
||||
enable32bits ? true,
|
||||
writeTextFile,
|
||||
shellcheck,
|
||||
pcre,
|
||||
runCommand,
|
||||
linuxPackages,
|
||||
fetchurl,
|
||||
lib,
|
||||
runtimeShell,
|
||||
bumblebee,
|
||||
libglvnd,
|
||||
vulkan-validation-layers,
|
||||
mesa,
|
||||
libvdpau-va-gl,
|
||||
intel-media-driver,
|
||||
vaapiIntel,
|
||||
pkgsi686Linux,
|
||||
driversi686Linux,
|
||||
zlib,
|
||||
libdrm,
|
||||
xorg,
|
||||
wayland,
|
||||
gcc,
|
||||
}: let
|
||||
writeExecutable = {
|
||||
name,
|
||||
text,
|
||||
}:
|
||||
|
||||
let
|
||||
writeExecutable = { name, text }:
|
||||
writeTextFile {
|
||||
inherit name text;
|
||||
|
||||
|
@ -62,17 +63,18 @@ let
|
|||
It contains the builder for different nvidia configuration, parametrized by
|
||||
the version of the driver and sha256 sum of the driver installer file.
|
||||
*/
|
||||
nvidiaPackages = { version, sha256 ? fetch_db."${version}".sha256 }:
|
||||
let
|
||||
nvidiaDrivers = (linuxPackages.nvidia_x11.override { }).overrideAttrs
|
||||
nvidiaPackages = {
|
||||
version,
|
||||
sha256 ? fetch_db."${version}".sha256,
|
||||
}: let
|
||||
nvidiaDrivers =
|
||||
(linuxPackages.nvidia_x11.override {}).overrideAttrs
|
||||
(oldAttrs: {
|
||||
pname = "nvidia";
|
||||
name = "nvidia-x11-${version}-nixGL";
|
||||
inherit version;
|
||||
src =
|
||||
let
|
||||
url =
|
||||
"https://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}.run";
|
||||
src = let
|
||||
url = "https://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}.run";
|
||||
in
|
||||
fetchurl {inherit url sha256;};
|
||||
useGLVND = true;
|
||||
|
@ -94,8 +96,7 @@ let
|
|||
${''export __EGL_VENDOR_LIBRARY_FILENAMES=''${NVIDIA_JSON[*]}${
|
||||
lib.optionalString enable32bits
|
||||
'':''${NVIDIA_JSON32[*]}''
|
||||
}"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"''
|
||||
}
|
||||
}"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"''}
|
||||
|
||||
${
|
||||
lib.optionalString (api == "Vulkan")
|
||||
|
@ -115,8 +116,7 @@ let
|
|||
exec "$@"
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
in {
|
||||
inherit nvidiaDrivers nvidiaLibsOnly;
|
||||
|
||||
nixGLNvidiaBumblebee = writeExecutable {
|
||||
|
@ -154,31 +154,34 @@ let
|
|||
nixGLIntel = writeExecutable {
|
||||
name = "nixGLIntel";
|
||||
# add the 32 bits drivers if needed
|
||||
text =
|
||||
let
|
||||
mesa-drivers = [ mesa.drivers ]
|
||||
text = let
|
||||
mesa-drivers =
|
||||
[mesa.drivers]
|
||||
++ lib.optional enable32bits pkgsi686Linux.mesa.drivers;
|
||||
intel-driver = [ intel-media-driver vaapiIntel ]
|
||||
intel-driver =
|
||||
[intel-media-driver vaapiIntel]
|
||||
# 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 ];
|
||||
libvdpau = [ libvdpau-va-gl ]
|
||||
++ lib.optionals enable32bits [
|
||||
/*
|
||||
pkgsi686Linux.intel-media-driver
|
||||
*/
|
||||
driversi686Linux.vaapiIntel
|
||||
];
|
||||
libvdpau =
|
||||
[libvdpau-va-gl]
|
||||
++ lib.optional enable32bits pkgsi686Linux.libvdpau-va-gl;
|
||||
glxindirect = runCommand "mesa_glxindirect" { } (
|
||||
''
|
||||
glxindirect = runCommand "mesa_glxindirect" {} ''
|
||||
mkdir -p $out/lib
|
||||
ln -s ${mesa.drivers}/lib/libGLX_mesa.so.0 $out/lib/libGLX_indirect.so.0
|
||||
''
|
||||
);
|
||||
in
|
||||
''
|
||||
'';
|
||||
in ''
|
||||
#!${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
|
||||
":${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 "$@"
|
||||
'';
|
||||
|
@ -186,8 +189,7 @@ let
|
|||
|
||||
nixVulkanIntel = writeExecutable {
|
||||
name = "nixVulkanIntel";
|
||||
text =
|
||||
let
|
||||
text = let
|
||||
# generate a file with the listing of all the icd files
|
||||
icd = runCommand "mesa_icd" {} (
|
||||
# 64 bits icd
|
||||
|
@ -201,8 +203,7 @@ let
|
|||
# concat everything as a one line string with ":" as seperator
|
||||
+ ''cat f | xargs | sed "s/ /:/g" > $out''
|
||||
);
|
||||
in
|
||||
''
|
||||
in ''
|
||||
#!${runtimeShell}
|
||||
if [ -n "$LD_LIBRARY_PATH" ]; then
|
||||
echo "Warning, nixVulkanIntel overwriting existing LD_LIBRARY_PATH" 1>&2
|
||||
|
@ -232,11 +233,10 @@ let
|
|||
cp ${nixGL}/bin/* "$out/bin/nixGL";
|
||||
'';
|
||||
|
||||
auto =
|
||||
let
|
||||
auto = let
|
||||
_nvidiaVersionFile =
|
||||
if nvidiaVersionFile != null then
|
||||
nvidiaVersionFile
|
||||
if nvidiaVersionFile != null
|
||||
then nvidiaVersionFile
|
||||
else
|
||||
# HACK: Get the version from /proc. It turns out that /proc is mounted
|
||||
# inside of the build sandbox and varies from machine to machine.
|
||||
|
@ -255,15 +255,17 @@ let
|
|||
# The nvidia version. Either fixed by the `nvidiaVersion` argument, or
|
||||
# auto-detected. Auto-detection is impure.
|
||||
nvidiaVersionAuto =
|
||||
if nvidiaVersion != null then
|
||||
nvidiaVersion
|
||||
if nvidiaVersion != null
|
||||
then nvidiaVersion
|
||||
else
|
||||
# Get if from the nvidiaVersionFile
|
||||
let
|
||||
data = builtins.readFile _nvidiaVersionFile;
|
||||
versionMatch = builtins.match ".*Module ([0-9.]+) .*" data;
|
||||
in
|
||||
if versionMatch != null then builtins.head versionMatch else null;
|
||||
if versionMatch != null
|
||||
then builtins.head versionMatch
|
||||
else null;
|
||||
|
||||
autoNvidia = nvidiaPackages {version = nvidiaVersionAuto;};
|
||||
in
|
||||
|
@ -271,18 +273,21 @@ let
|
|||
# The output derivation contains nixGL which point either to
|
||||
# nixGLNvidia or nixGLIntel using an heuristic.
|
||||
nixGLDefault =
|
||||
if nvidiaVersionAuto != null then
|
||||
nixGLCommon autoNvidia.nixGLNvidia
|
||||
else
|
||||
nixGLCommon nixGLIntel;
|
||||
} // autoNvidia;
|
||||
if nvidiaVersionAuto != null
|
||||
then nixGLCommon autoNvidia.nixGLNvidia
|
||||
else nixGLCommon nixGLIntel;
|
||||
}
|
||||
// autoNvidia;
|
||||
};
|
||||
in
|
||||
top // (if nvidiaVersion != null then
|
||||
top
|
||||
// (
|
||||
if nvidiaVersion != null
|
||||
then
|
||||
top.nvidiaPackages
|
||||
{
|
||||
version = nvidiaVersion;
|
||||
sha256 = nvidiaHash;
|
||||
}
|
||||
else
|
||||
{ })
|
||||
else {}
|
||||
)
|
||||
|
|
25
secrets.nix
25
secrets.nix
|
@ -1,22 +1,29 @@
|
|||
# WARNING: currently not usable anymore
|
||||
let
|
||||
inherit ((import
|
||||
inherit
|
||||
((
|
||||
import
|
||||
(
|
||||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
}
|
||||
)
|
||||
{src = ./.;}
|
||||
).defaultNix) secrets;
|
||||
)
|
||||
.defaultNix)
|
||||
secrets
|
||||
;
|
||||
inherit (secrets) pubKeys;
|
||||
inherit (pubKeys) users hosts;
|
||||
all = users // hosts;
|
||||
c_ = builtins;
|
||||
in
|
||||
{
|
||||
"secrets/s3fs.age".publicKeys = c_.attrValues (all);
|
||||
"secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues (all);
|
||||
"secrets/_nhitrl.age".publicKeys = c_.attrValues (all);
|
||||
"secrets/wifi.env.age".publicKeys = c_.attrValues (all);
|
||||
in {
|
||||
"secrets/s3fs.age".publicKeys = c_.attrValues all;
|
||||
"secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues all;
|
||||
"secrets/_nhitrl.age".publicKeys = c_.attrValues all;
|
||||
"secrets/wifi.env.age".publicKeys = c_.attrValues all;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# TODO: put ssh keys as user/host config
|
||||
inputs:
|
||||
let
|
||||
inputs: let
|
||||
# user-specific (~/.ssh/id_ed25519.pub)
|
||||
users = {
|
||||
"hungtr@bao" = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK+1+gps6phbZboIb9fH51VNPUCkhSSOAbkI3tq3Ou0Z";
|
||||
|
@ -12,9 +11,8 @@ let
|
|||
all = users // systems;
|
||||
# stands for calculus
|
||||
c_ = builtins;
|
||||
in
|
||||
{
|
||||
"system/secrets/s3fs.age".publicKeys = c_.attrValues (all);
|
||||
"system/secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues (all);
|
||||
"system/secrets/_nhitrl.age".publicKeys = c_.attrValues (all);
|
||||
in {
|
||||
"system/secrets/s3fs.age".publicKeys = c_.attrValues all;
|
||||
"system/secrets/s3fs.digital-garden.age".publicKeys = c_.attrValues all;
|
||||
"system/secrets/_nhitrl.age".publicKeys = c_.attrValues all;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# This uses the exported devShells from flake.nix
|
||||
# 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
|
||||
(import
|
||||
(
|
||||
import
|
||||
(
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in (import ./c_.nix).fetchTree lock.nodes.flake-compat.locked
|
||||
in
|
||||
(import ./c_.nix).fetchTree lock.nodes.flake-compat.locked
|
||||
)
|
||||
{src = ./.;}
|
||||
).shellNix
|
||||
)
|
||||
.shellNix
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# TODO: templates should be able to have initial states like
|
||||
# repo name, author,...
|
||||
{ pkgs
|
||||
, lib
|
||||
, ...
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
rust = {
|
||||
path = ./rust;
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
)
|
||||
{
|
||||
src = ./.;
|
||||
}).defaultNix
|
||||
})
|
||||
.defaultNix
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
{
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
}: let
|
||||
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
|
||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
|
||||
in
|
||||
{
|
||||
in {
|
||||
packages = forAllSystems (system: {
|
||||
default = pkgs.${system}.poetry2nix.mkPoetryApplication {projectDir = self;};
|
||||
});
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
)
|
||||
{
|
||||
src = ./.;
|
||||
}).shellNix
|
||||
})
|
||||
.shellNix
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
)
|
||||
{
|
||||
src = ./.;
|
||||
}).defaultNix
|
||||
})
|
||||
.defaultNix
|
||||
|
|
|
@ -6,23 +6,29 @@
|
|||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils, naersk, rust-overlay }:
|
||||
utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
utils,
|
||||
naersk,
|
||||
rust-overlay,
|
||||
}:
|
||||
utils.lib.eachDefaultSystem (system: let
|
||||
overlays = [rust-overlay.overlays.default];
|
||||
pkgs = import nixpkgs {inherit system overlays;};
|
||||
rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith
|
||||
rust_pkgs =
|
||||
pkgs.rust-bin.selectLatestNightlyWith
|
||||
(
|
||||
toolchain:
|
||||
toolchain.default.override {
|
||||
extensions = ["rust-src" "rust-analyzer" "rust-docs" "clippy" "miri"];
|
||||
}
|
||||
));
|
||||
);
|
||||
naersk-lib = pkgs.callPackage naersk {};
|
||||
in
|
||||
{
|
||||
in {
|
||||
defaultPackage = naersk-lib.buildPackage ./.;
|
||||
devShell = with pkgs; mkShell {
|
||||
devShell = with pkgs;
|
||||
mkShell {
|
||||
buildInputs = [
|
||||
rust_pkgs
|
||||
# rust's compiler is quite powerful enough to the point where
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
)
|
||||
{
|
||||
src = ./.;
|
||||
}).shellNix
|
||||
})
|
||||
.shellNix
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
)
|
||||
{
|
||||
src = ./.;
|
||||
}).defaultNix
|
||||
})
|
||||
.defaultNix
|
||||
|
|
|
@ -6,23 +6,29 @@
|
|||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils, naersk, rust-overlay }:
|
||||
utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
utils,
|
||||
naersk,
|
||||
rust-overlay,
|
||||
}:
|
||||
utils.lib.eachDefaultSystem (system: let
|
||||
overlays = [rust-overlay.overlays.default];
|
||||
pkgs = import nixpkgs {inherit system overlays;};
|
||||
rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith
|
||||
rust_pkgs =
|
||||
pkgs.rust-bin.selectLatestNightlyWith
|
||||
(
|
||||
toolchain:
|
||||
toolchain.default.override {
|
||||
extensions = ["rust-src" "rust-analyzer" "rust-docs" "clippy" "miri"];
|
||||
}
|
||||
));
|
||||
);
|
||||
naersk-lib = pkgs.callPackage naersk {};
|
||||
in
|
||||
{
|
||||
in {
|
||||
defaultPackage = naersk-lib.buildPackage ./.;
|
||||
devShell = with pkgs; mkShell {
|
||||
devShell = with pkgs;
|
||||
mkShell {
|
||||
buildInputs = [
|
||||
rust_pkgs
|
||||
# rust's compiler is quite powerful enough to the point where
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
)
|
||||
{
|
||||
src = ./.;
|
||||
}).shellNix
|
||||
})
|
||||
.shellNix
|
||||
|
|
|
@ -9,20 +9,26 @@
|
|||
turbo.url = "github:dlip/turbo";
|
||||
};
|
||||
|
||||
outputs = { self, turbo, flake-utils, nixpkgs }:
|
||||
with flake-utils; lib.eachSystem lib.defaultSystems (sys:
|
||||
let
|
||||
outputs = {
|
||||
self,
|
||||
turbo,
|
||||
flake-utils,
|
||||
nixpkgs,
|
||||
}:
|
||||
with flake-utils; lib.eachSystem lib.defaultSystems (sys: let
|
||||
overlays = [turbo.overlay];
|
||||
# pkgs is our tweaked nixpkgs
|
||||
pkgs = import nixpkgs { system = sys; overlays = overlays; };
|
||||
pkgs = import nixpkgs {
|
||||
system = sys;
|
||||
overlays = overlays;
|
||||
};
|
||||
shellMsg = ''
|
||||
echo "Hello from nix ${sys}"
|
||||
echo "Local development may use our remote planetscale database (pscale login && pnpm dev:infra; pnpm dev)"
|
||||
echo "Or from the specified docker-compose.yml (pnpm dev:local_infra && pnpm dev)"
|
||||
echo "See more on CONTRIBUTING.md"
|
||||
'';
|
||||
in
|
||||
{
|
||||
in {
|
||||
devShell = pkgs.mkShell {
|
||||
nativeBuildInputs = [pkgs.bashInteractive];
|
||||
buildInputs = [
|
||||
|
@ -47,7 +53,8 @@
|
|||
export PRISMA_FMT_BINARY="${pkgs.prisma-engines}/bin/prisma-fmt"
|
||||
export TURBO_BINARY_PATH="${pkgs.turbo}/bin/turbo"
|
||||
pnpm install
|
||||
'' + shellMsg;
|
||||
''
|
||||
+ shellMsg;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
{ lib, ... }@inputs:
|
||||
let
|
||||
{lib, ...} @ inputs: let
|
||||
config = {
|
||||
hungtr.metadata = {};
|
||||
"hungtr@bao".metadata = {
|
||||
ssh_pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK+1+gps6phbZboIb9fH51VNPUCkhSSOAbkI3tq3Ou0Z";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
in {
|
||||
homeConfigurations = {};
|
||||
pubKeys = lib.getPubkey config;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue