merge into a single flake

However, Nix has some annoying store semantics when integrating with
.git repos, so I move .git to .git.bak whenever I'm not working with
git.
This commit is contained in:
chayleaf 2023-05-25 04:39:57 +07:00
parent 92dc5eb16e
commit 4f531a83a9
13 changed files with 287 additions and 288 deletions

View file

@ -1,11 +1,12 @@
# My Nix config
To install, put `system` to `/etc/nixos`, put `home` to
`~/.config/home-manager` (and `overlays.nix` to `~/.config/nixpkgs`)
To install, simply run `nixos-rebuild switch --flake .` and
`home-manager switch --flake .`.
The reason they are separate is because I want to be able to iterate
home config quickly, and `nixos-rebuild`'ing the entire system for every
little change is pretty annoying (not to mention the necessity of
`sudo`). I'll probably merge them later, especially after
[Tvix](https://tvl.fyi/blog/rewriting-nix) becomes feature-complete.
The reason I don't use the NixOS home-manager module is is because I
want to be able to iterate home config quickly, and `nixos-rebuild`'ing
the entire system for every little change is pretty annoying (not to
mention the necessity of `sudo`). I'll probably merge them later,
especially after [Tvix](https://tvl.fyi/blog/rewriting-nix) becomes
feature-complete.

View file

@ -32,6 +32,24 @@
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1675933616,
"narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "47478a4a003e745402acf63be7f9a092d51b83d7",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
@ -65,13 +83,33 @@
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1684824189,
"narHash": "sha256-k3nCkn5Qy67rCguuw6YkGuL6hOUNRKxQoKOjnapk5sU=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "58eb968c21d309a6c2b020ea8d64e25c38ceebba",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"impermanence": {
"locked": {
"lastModified": 1682268411,
"narHash": "sha256-ICDKQ7tournRVtfM8C2II0qHiOZOH1b3dXVOCsgr11o=",
"lastModified": 1684264534,
"narHash": "sha256-K0zr+ry3FwIo3rN2U/VWAkCJSgBslBisvfRIPwMbuCQ=",
"owner": "nix-community",
"repo": "impermanence",
"rev": "df1692e2d9f1efc4300b1ea9201831730e0b817d",
"rev": "89253fb1518063556edd5e54509c30ac3089d5e6",
"type": "github"
},
"original": {
@ -82,16 +120,17 @@
},
"nix-gaming": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1683465499,
"narHash": "sha256-7dufJBJ/AY4vd5x+2kR9Xj39ydmFf9JhzoDAF/NxeLM=",
"lastModified": 1684835544,
"narHash": "sha256-RfxqpIUbVDcKsTw/e4Oc+ywrmWX1p4JrAOfpPFVXZ0k=",
"owner": "fufexan",
"repo": "nix-gaming",
"rev": "6e2819c51586b34106360e261bad1e1c4d4f783b",
"rev": "057ae3f4ded2a24fecd674a861bc7e08ad74b3ca",
"type": "github"
},
"original": {
@ -102,11 +141,11 @@
},
"nixos-hardware": {
"locked": {
"lastModified": 1683269598,
"narHash": "sha256-KNsb+nBbB1Fmxd07dt4E0KXMT4YeKJB7gQaA6Xfk+mo=",
"lastModified": 1684899633,
"narHash": "sha256-NtwerXX8UFsoNy6k+DukJMriWtEjQtMU/Urbff2O2Dg=",
"owner": "NixOS",
"repo": "nixos-hardware",
"rev": "51559e691f1493a26f94f1df1aaf516bb507e78b",
"rev": "4cc688ee711159b9bcb5a367be44007934e1a49d",
"type": "github"
},
"original": {
@ -128,11 +167,11 @@
"utils": "utils"
},
"locked": {
"lastModified": 1671738303,
"narHash": "sha256-PRgqtaWf2kMSYqVmcnmhTh+UsC0RmvXRTr+EOw5VZUA=",
"lastModified": 1684962389,
"narHash": "sha256-pGAbDgIusNLVUFF5BcfI8ZPQGuQvMmlINOJUztHZrsg=",
"owner": "simple-nixos-mailserver",
"repo": "nixos-mailserver",
"rev": "6d0d9fb966cc565a3df74d3b686f924c7615118c",
"rev": "fd605a419bcad2513844ccee0fc6f7760cdd657e",
"type": "gitlab"
},
"original": {
@ -143,11 +182,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1683408522,
"narHash": "sha256-9kcPh6Uxo17a3kK3XCHhcWiV1Yu1kYj22RHiymUhMkU=",
"lastModified": 1684844536,
"narHash": "sha256-M7HhXYVqAuNb25r/d3FOO0z4GxPqDIZp5UjHFbBgw0Q=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "897876e4c484f1e8f92009fd11b7d988a121a4e7",
"rev": "d30264c2691128adc261d7c9388033645f0e742b",
"type": "github"
},
"original": {
@ -157,13 +196,70 @@
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1675183161,
"narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"notlua": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1684668267,
"narHash": "sha256-AKnX12OwVEqXDv8Th2QDT96MPvC8Zv5KCtVdqc7l3hY=",
"owner": "chayleaf",
"repo": "notlua",
"rev": "469652092f4f2e951b0db29027b05346b32d8122",
"type": "github"
},
"original": {
"owner": "chayleaf",
"repo": "notlua",
"rev": "469652092f4f2e951b0db29027b05346b32d8122",
"type": "github"
}
},
"nur": {
"locked": {
"lastModified": 1684959207,
"narHash": "sha256-lROs3YxWZDGeEPrcv0AYEfyps+gSW01E/VoTkmHU768=",
"owner": "nix-community",
"repo": "NUR",
"rev": "c4e46e935ba827acf70979c5e02a8431cf14cc5a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "NUR",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"impermanence": "impermanence",
"nix-gaming": "nix-gaming",
"nixos-hardware": "nixos-hardware",
"nixos-mailserver": "nixos-mailserver",
"nixpkgs": "nixpkgs",
"notlua": "notlua",
"nur": "nur",
"rust-overlay": "rust-overlay",
"utils": "utils_2"
}
@ -176,11 +272,11 @@
]
},
"locked": {
"lastModified": 1683708507,
"narHash": "sha256-i5zgWcuyZcNBnlrzVjhpAFQdJWr4OyhvQ1owAEHFFKw=",
"lastModified": 1684894917,
"narHash": "sha256-kwKCfmliHIxKuIjnM95TRcQxM/4AAEIZ+4A9nDJ6cJs=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "ed55dc022aa23ed3c42f383cf1782290b3b939d5",
"rev": "9ea38d547100edcf0da19aaebbdffa2810585495",
"type": "github"
},
"original": {

143
flake.nix Normal file
View file

@ -0,0 +1,143 @@
{
description = "NixOS + Home Manager configuration of chayleaf";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
utils.url = "github:gytis-ivaskevicius/flake-utils-plus";
nixos-hardware.url = "github:NixOS/nixos-hardware";
impermanence.url = "github:nix-community/impermanence";
nur.url = "github:nix-community/NUR";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-gaming = {
url = "github:fufexan/nix-gaming";
inputs.nixpkgs.follows = "nixpkgs";
};
notlua = {
url = "github:chayleaf/notlua/469652092f4f2e951b0db29027b05346b32d8122";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-mailserver = {
url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-22_11.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nixpkgs, utils, nixos-hardware, impermanence, home-manager, nur, nix-gaming, notlua, nixos-mailserver, ... }:
let
# IRL-related stuff I'd rather not put into git
priv =
if builtins.pathExists ./private.nix then (import ./private.nix)
else if builtins.pathExists ./private/default.nix then (import ./private)
else { };
getOr = def: s: x: with builtins; if hasAttr s x then getAttr s x else def;
getPriv = hostname: getOr { } hostname priv;
getPrivSys = hostname: getOr { } "system" (getPriv hostname);
getPrivUser = hostname: user: getOr { } user (getPriv hostname);
lib = nixpkgs.lib // {
quoteListenAddr = addr:
if nixpkgs.lib.hasInfix ":" addr then "[${addr}]" else addr;
};
config = {
nixmsi = rec {
system = "x86_64-linux";
modules = [
nix-gaming.nixosModules.pipewireLowLatency
./system/hardware/msi_delta_15.nix
./system/hosts/nixmsi.nix
];
home.user = {
pkgs = import nixpkgs {
inherit system;
binaryCachePublicKeys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
# "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
];
binaryCaches = [
"https://cache.nixos.org"
# "https://nixpkgs-wayland.cachix.org"
];
overlays = [
(self: super: import ./home/pkgs {
# can't use callPackage here, idk why
pkgs = super;
lib = super.lib;
nur = import nur {
pkgs = super;
nurpkgs = super;
};
nix-gaming = nix-gaming.packages.${system};
})
];
};
extraSpecialArgs = {
notlua = notlua.lib.${system};
# pkgs-wayland = nixpkgs-wayland.packages.${system};
};
modules = [
nur.nixosModules.nur
./home/hosts/nixmsi.nix
];
};
};
nixserver = {
modules = [
nixos-mailserver.nixosModules.default
./system/hardware/hp_probook_g0.nix
./system/hosts/nixserver
];
};
router = {
system = "aarch64-linux";
modules = [
./system/hardware/bpi_r3.nix
./system/hosts/router
];
};
};
in utils.lib.mkFlake {
inherit self inputs;
hostDefaults.modules = [
./system/modules/vfio.nix
./system/modules/ccache.nix
./system/modules/impermanence.nix
./system/modules/common.nix
impermanence.nixosModule
];
hosts = builtins.mapAttrs (hostname: args @ { system ? "x86_64-linux", modules, ... }: {
inherit system;
modules = modules ++ [ (getPrivSys hostname) ];
extraArgs = {
inherit nixpkgs;
};
specialArgs = {
inherit lib;
hardware = nixos-hardware.nixosModules;
};
} // (builtins.removeAttrs args [ "home" "modules" ]))
config;
} // {
homeConfigurations =
builtins.foldl'
(a: b: a // b)
{ }
(builtins.concatLists
(lib.mapAttrsToList
(hostname: config:
lib.mapAttrsToList
(user: config@{ modules, ... }: {
"${user}@${hostname}" = home-manager.lib.homeManagerConfiguration (config // {
modules = config.modules ++ [ (getPrivUser hostname user) ];
});
})
(getOr { } "home" config))
config));
};
}

View file

@ -23,11 +23,11 @@
"pinned": false,
"src": {
"name": null,
"sha256": "sha256-gof4yL5sHPKXDC4mDfPyBIvPtWxxxVy6gHx58yoTEbQ=",
"sha256": "sha256-JYGwb0LhIs6B2/OHiU+mJ/dAAS+Dg+MrVksAsn6IS9g=",
"type": "url",
"url": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton8-2/GE-Proton8-2.tar.gz"
"url": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton8-3/GE-Proton8-3.tar.gz"
},
"version": "GE-Proton8-2"
"version": "GE-Proton8-3"
},
"yomichan": {
"cargoLocks": null,

View file

@ -11,10 +11,10 @@
};
proton-ge = {
pname = "proton-ge";
version = "GE-Proton8-2";
version = "GE-Proton8-3";
src = fetchurl {
url = "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton8-2/GE-Proton8-2.tar.gz";
sha256 = "sha256-gof4yL5sHPKXDC4mDfPyBIvPtWxxxVy6gHx58yoTEbQ=";
url = "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton8-3/GE-Proton8-3.tar.gz";
sha256 = "sha256-JYGwb0LhIs6B2/OHiU+mJ/dAAS+Dg+MrVksAsn6IS9g=";
};
};
yomichan = {

View file

@ -29,7 +29,7 @@ in {
];
extraPython3Packages = (pypkgs: with pypkgs; [ python-lsp-server ]);
};
languages = [];
# languages = [];
settings = {
theme = "base16_terminal";
};

View file

@ -1,104 +0,0 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1683651229,
"narHash": "sha256-HN0Mw8g1XQIrcdyzqT00YW0Uqi/V/BUUUAgvcK1pcSM=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "983f8a1bb965b261492123cd8e2d07da46d4d50a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nix-gaming": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1683465499,
"narHash": "sha256-7dufJBJ/AY4vd5x+2kR9Xj39ydmFf9JhzoDAF/NxeLM=",
"owner": "fufexan",
"repo": "nix-gaming",
"rev": "6e2819c51586b34106360e261bad1e1c4d4f783b",
"type": "github"
},
"original": {
"owner": "fufexan",
"repo": "nix-gaming",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1683408522,
"narHash": "sha256-9kcPh6Uxo17a3kK3XCHhcWiV1Yu1kYj22RHiymUhMkU=",
"path": "/nix/store/zjpd6dn9kza8zl3l17cwgyifsxbvi3nb-source",
"rev": "897876e4c484f1e8f92009fd11b7d988a121a4e7",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"notlua": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1684668267,
"narHash": "sha256-AKnX12OwVEqXDv8Th2QDT96MPvC8Zv5KCtVdqc7l3hY=",
"owner": "chayleaf",
"repo": "notlua",
"rev": "469652092f4f2e951b0db29027b05346b32d8122",
"type": "github"
},
"original": {
"owner": "chayleaf",
"repo": "notlua",
"rev": "469652092f4f2e951b0db29027b05346b32d8122",
"type": "github"
}
},
"nur": {
"locked": {
"lastModified": 1683707801,
"narHash": "sha256-fEoovtx4OXwftUoiRTnPP+dCDJKUE3KXO/rKxNqueQ8=",
"owner": "nix-community",
"repo": "NUR",
"rev": "c524842d10fe65f19e0bb544b39d805e0b5d6d8e",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "NUR",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nix-gaming": "nix-gaming",
"nixpkgs": "nixpkgs",
"notlua": "notlua",
"nur": "nur"
}
}
},
"root": "root",
"version": 7
}

View file

@ -1,65 +0,0 @@
{
description = "Home Manager configuration of chayleaf";
inputs = {
#nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
#instead take it from system config
nur.url = "github:nix-community/NUR";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-gaming = {
url = "github:fufexan/nix-gaming";
inputs.nixpkgs.follows = "nixpkgs";
};
notlua = {
url = "github:chayleaf/notlua/469652092f4f2e951b0db29027b05346b32d8122";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager, nur, nix-gaming, notlua }:
let
# IRL-related private config
priv = if builtins.pathExists ./private.nix then (import ./private.nix) else {};
getPriv = (hostname: with builtins; if hasAttr hostname priv then (getAttr hostname priv) else {});
in {
homeConfigurations = {
"user@nixmsi" = let system = "x86_64-linux"; in home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs {
inherit system;
binaryCachePublicKeys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
# "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
];
binaryCaches = [
"https://cache.nixos.org"
# "https://nixpkgs-wayland.cachix.org"
];
overlays = [
(self: super: import ./pkgs {
# can't use callPackage here, idk why
pkgs = super;
lib = super.lib;
nur = import nur {
pkgs = super;
nurpkgs = super;
};
})
nix-gaming.overlays.default
];
};
extraSpecialArgs = {
notlua = notlua.lib.${system};
# pkgs-wayland = nixpkgs-wayland.packages.${system};
};
modules = [
nur.nixosModules.nur
./hosts/nixmsi.nix
(getPriv "nixmsi")
];
};
};
};
}

View file

@ -1,6 +1,7 @@
{ pkgs
, lib
, nur
, nix-gaming
, ... }:
let
inherit (pkgs) callPackage;
@ -10,6 +11,7 @@ let
in
{
osu-lazer-bin = nix-gaming.osu-lazer-bin;
clang-tools_latest = pkgs.clang-tools_15;
clang_latest = pkgs.clang_15;
home-daemon = callPackage ./home-daemon { };

2
prepush.sh Executable file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
mv .git.bak .git

View file

@ -1,4 +1,4 @@
#!/usr/bin/env bash
git push
git push github master
mv .git .git.bak

View file

@ -1,81 +0,0 @@
{
description = "NixOS configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
utils.url = "github:gytis-ivaskevicius/flake-utils-plus";
nixos-hardware.url = "github:NixOS/nixos-hardware";
impermanence.url = "github:nix-community/impermanence";
# simply make rust-overlay available for the whole system
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-gaming = {
url = "github:fufexan/nix-gaming";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-mailserver = {
url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-22_11.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nixpkgs, utils, nixos-hardware, impermanence, nix-gaming, nixos-mailserver, ... }:
let
# IRL-related stuff I'd rather not put into git
priv =
if builtins.pathExists ./private.nix then (import ./private.nix)
else if builtins.pathExists ./private/default.nix then (import ./private)
else { };
getPriv = hostname: with builtins; if hasAttr hostname priv then getAttr hostname priv else { };
common = hostname: [ (getPriv hostname) ];
lib = nixpkgs.lib // {
quoteListenAddr = addr:
if nixpkgs.lib.hasInfix ":" addr then "[${addr}]" else addr;
};
mkHost = args @ { system ? "x86_64-linux", modules, ... }: {
inherit system;
extraArgs = {
inherit nixpkgs;
};
specialArgs = {
inherit lib;
hardware = nixos-hardware.nixosModules;
};
} // args;
in utils.lib.mkFlake {
inherit self inputs;
hostDefaults.modules = [
./modules/vfio.nix
./modules/ccache.nix
./modules/impermanence.nix
./modules/common.nix
impermanence.nixosModule
];
hosts = builtins.mapAttrs (_: mkHost) {
nixmsi = {
modules = [
nix-gaming.nixosModules.pipewireLowLatency
./hardware/msi_delta_15.nix
./hosts/nixmsi.nix
] ++ common "nixmsi";
};
nixserver = {
modules = [
nixos-mailserver.nixosModules.default
./hardware/hp_probook_g0.nix
./hosts/nixserver
] ++ common "nixserver";
};
router = {
system = "aarch64-linux";
modules = [
./hardware/bpi_r3.nix
./hosts/router
];
};
};
};
}

View file

@ -1,6 +1,11 @@
#!/usr/bin/env bash
rm -rf ./home ./system
cp -r /etc/nixos ./system
cp -r ~/.config/home-manager ./home
cp ~/.config/nixpkgs/overlays.nix ./overlays.nix
cp ~/.config/nixpkgs/overlays.nix ./overlays.nix || echo "probably no overlays exist"
nix flake update
nvfetcher \
-o ./home/_sources \
-c ./home/nvfetcher.toml || echo "failed to update nvfetcher sources"
mozilla-addons-to-nix \
./home/pkgs/firefox-addons/addons.json \
./home/pkgs/firefox-addons/generated.nix || echo "failed to update firefox addons"
s nixos-rebuild switch --flake . || sudo nixos-rebuild switch --flake .
home-manager switch --flake .