move to using flake-utils-plus

This commit is contained in:
Dmitriy Kholkin 2022-10-01 22:49:29 +03:00
parent 7c2bbb4df7
commit 0e9a727a37
2 changed files with 110 additions and 228 deletions

189
flake.lock generated
View File

@ -105,25 +105,6 @@
"type": "github"
}
},
"devshell": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1653917170,
"narHash": "sha256-FyxOnEE/V4PNEcMU62ikY4FfYPo349MOhMM97HS0XEo=",
"owner": "numtide",
"repo": "devshell",
"rev": "fc7a3e3adde9bbcab68af6d1e3c6eb738e296a92",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@ -157,22 +138,6 @@
}
},
"flake-compat_3": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_4": {
"flake": false,
"locked": {
"lastModified": 1648199409,
@ -190,11 +155,11 @@
},
"flake-utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
@ -203,13 +168,32 @@
"type": "github"
}
},
"flake-utils-plus": {
"inputs": {
"flake-utils": "flake-utils"
},
"locked": {
"lastModified": 1664562030,
"narHash": "sha256-ZakfsWb+v78jmtpQpwNYETuPyY2GJYVqGF6agZGGQAg=",
"owner": "alukardbf",
"repo": "flake-utils-plus",
"rev": "a9b6b680c287791edcb0891da44eeb53ec787a2a",
"type": "github"
},
"original": {
"owner": "alukardbf",
"ref": "v1.3.1-fix",
"repo": "flake-utils-plus",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
@ -233,40 +217,6 @@
"type": "github"
}
},
"flake-utils_4": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"fup": {
"inputs": {
"flake-utils": "flake-utils_2"
},
"locked": {
"lastModified": 1638172912,
"narHash": "sha256-jxhQGNEsZTdop/Br3JPS+xmBf6t9cIWRzVZFxbT76Rw=",
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"rev": "166d6ebd9f0de03afc98060ac92cba9c71cfe550",
"type": "github"
},
"original": {
"owner": "gytis-ivaskevicius",
"ref": "v1.3.1",
"repo": "flake-utils-plus",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -311,7 +261,7 @@
},
"lib-aggregate": {
"inputs": {
"flake-utils": "flake-utils_4",
"flake-utils": "flake-utils_3",
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
@ -360,29 +310,6 @@
"type": "github"
}
},
"miniguest": {
"inputs": {
"devshell": "devshell",
"flake-compat": "flake-compat_2",
"fup": "fup",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1659964474,
"narHash": "sha256-PK8yYgRg7IG07Town2pVWB0tmtBBzIXtX5pqssHW6B4=",
"owner": "lourkeur",
"repo": "miniguest",
"rev": "dd5c5ef2dc4933bcb0504d7120c410219de607e2",
"type": "github"
},
"original": {
"owner": "lourkeur",
"repo": "miniguest",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": [
@ -408,7 +335,7 @@
"nix": {
"inputs": {
"lowdown-src": "lowdown-src",
"nixpkgs": "nixpkgs_3",
"nixpkgs": "nixpkgs_2",
"nixpkgs-regression": "nixpkgs-regression"
},
"locked": {
@ -427,7 +354,7 @@
},
"nix-alien": {
"inputs": {
"flake-utils": "flake-utils_3",
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
],
@ -513,22 +440,6 @@
"type": "indirect"
}
},
"nixpkgs-custom": {
"locked": {
"lastModified": 1659321066,
"narHash": "sha256-lWv1/yZhz1XGgpkyOSBItVyIDkiAIGXw8CHAA8+X144=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "894bced14f7c66112d39233bcaeaaf708e077759",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"rev": "894bced14f7c66112d39233bcaeaaf708e077759",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1663463003,
@ -560,22 +471,6 @@
"type": "github"
}
},
"nixpkgs-mozilla": {
"flake": false,
"locked": {
"lastModified": 1657214286,
"narHash": "sha256-rO/4oymKXU09wG2bcTt4uthPCp1XsBZjxuCJo3yVXNs=",
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"rev": "0508a66e28a5792fdfb126bbf4dec1029c2509e0",
"type": "github"
},
"original": {
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"type": "github"
}
},
"nixpkgs-regression": {
"locked": {
"lastModified": 1643052045,
@ -611,7 +506,7 @@
"nixpkgs-wayland": {
"inputs": {
"cachix": "cachix",
"flake-compat": "flake-compat_3",
"flake-compat": "flake-compat_2",
"lib-aggregate": "lib-aggregate",
"nixpkgs": [
"nixpkgs"
@ -632,22 +527,6 @@
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1643381941,
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1657693803,
"narHash": "sha256-G++2CJ9u0E7NNTAi9n5G8TdDmGJXcIjkJ3NF8cetQB8=",
@ -663,7 +542,7 @@
"type": "github"
}
},
"nixpkgs_4": {
"nixpkgs_3": {
"locked": {
"lastModified": 1663850217,
"narHash": "sha256-tp9nXo1/IdN/xN9m06ryy0QUAEfoN6K56ObM/1QTAjc=",
@ -721,7 +600,7 @@
},
"polymc": {
"inputs": {
"flake-compat": "flake-compat_4",
"flake-compat": "flake-compat_3",
"libnbtplusplus": "libnbtplusplus",
"nixpkgs": [
"nixpkgs"
@ -780,16 +659,14 @@
"base16": "base16",
"base16-tokyonight-scheme": "base16-tokyonight-scheme",
"comma": "comma",
"flake-utils-plus": "flake-utils-plus",
"home-manager": "home-manager",
"hyprland": "hyprland",
"miniguest": "miniguest",
"nix": "nix",
"nix-alien": "nix-alien",
"nixos-generators": "nixos-generators",
"nixpkgs": "nixpkgs_4",
"nixpkgs-custom": "nixpkgs-custom",
"nixpkgs": "nixpkgs_3",
"nixpkgs-master": "nixpkgs-master",
"nixpkgs-mozilla": "nixpkgs-mozilla",
"nixpkgs-stable": "nixpkgs-stable",
"nixpkgs-wayland": "nixpkgs-wayland",
"nur": "nur",

149
flake.nix
View File

@ -2,10 +2,10 @@
description = "System configuration";
inputs = {
flake-utils-plus.url = "github:alukardbf/flake-utils-plus/v1.3.1-fix";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-master.url = "github:nixos/nixpkgs/master";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-22.05";
nixpkgs-custom.url = "github:nixos/nixpkgs/894bced14f7c66112d39233bcaeaaf708e077759";
nixpkgs-wayland = {
url = "github:nix-community/nixpkgs-wayland";
inputs.nixpkgs.follows = "nixpkgs";
@ -28,10 +28,10 @@
url = "github:nix-community/comma";
inputs.nixpkgs.follows = "nixpkgs";
};
miniguest = {
url = "github:lourkeur/miniguest";
inputs.nixpkgs.follows = "nixpkgs";
};
# miniguest = {
# url = "github:lourkeur/miniguest";
# inputs.nixpkgs.follows = "nixpkgs";
# };
hyprland = {
url = "github:hyprwm/Hyprland";
inputs.nixpkgs.follows = "nixpkgs";
@ -44,10 +44,6 @@
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs-mozilla = {
url = "github:mozilla/nixpkgs-mozilla";
flake = false;
};
nur.url = github:nix-community/NUR;
polymc = {
url = "github:AquaVirus/PolyMC-Cracked";
@ -83,82 +79,91 @@
};
};
outputs = { self, nixpkgs, nixpkgs-stable, miniguest, nixos-generators, ... }@inputs:
let
rebuild = (pkgs: pkgs.writeShellScriptBin "rebuild" ''
outputs = { self, nixpkgs, nixos-generators, flake-utils-plus, ... }@inputs:
let
findModules = dir:
builtins.concatLists (builtins.attrValues (builtins.mapAttrs
(name: type:
if type == "regular" then
[{
name = builtins.elemAt (builtins.match "(.*)\\.nix" name) 0;
value = dir + "/${name}";
}]
else if (builtins.readDir (dir + "/${name}"))
? "default.nix" then [{
inherit name;
value = dir + "/${name}";
}] else
findModules (dir + "/${name}"))
(builtins.readDir dir)));
in flake-utils-plus.lib.mkFlake {
inherit self inputs;
supportedSystems = [ "x86_64-linux" ];
channelsConfig = { allowUnfree = true; };
channels.unstable.input = nixpkgs;
channels.unstable-zfs.input = nixpkgs;
channels.unstable-zfs.patches = [ ./patches/zen-kernels.patch ];
hostDefaults.system = "x86_64-linux";
hostDefaults.channelName = "unstable";
hosts = with nixpkgs.lib; let
hostnames = builtins.attrNames (builtins.readDir ./machines);
mkHost = name: {
system = builtins.readFile (./machines + "/${name}/system");
modules = [ (import (./machines + "/${name}")) { device = name; } ];
specialArgs = { inherit inputs; };
};
in (genAttrs hostnames mkHost) // {
# AMD-Workstation.channelName = "unstable-zfs";
};
outputsBuilder = channels: let
pkgs = channels.unstable;
rebuild = pkgs.writeShellScriptBin "rebuild" ''
if [[ -z $1 ]]; then
echo "Usage: $(basename $0) {switch|boot|test}"
elif [[ $1 = "iso" ]]; then
nix build .#nixosConfigurations.Flakes-ISO.config.system.build.isoImage "$@"
else
sudo nixos-rebuild $1 --flake . "$@"
arg=$1; shift;
sudo nixos-rebuild $arg --flake . "$@"
fi
'');
update-vscode = (pkgs: pkgs.writeShellScriptBin "update-vscode" ''
'';
update-vscode = pkgs.writeShellScriptBin "update-vscode" ''
./scripts/vscode_update_extensions.sh > ./profiles/applications/vscode/extensions.nix
'');
upgrade = (pkgs: pkgs.writeShellScriptBin "upgrade" ''
'';
upgrade = pkgs.writeShellScriptBin "upgrade" ''
cp flake.lock flake.lock.bak && nix flake update
update-vscode
'');
upgrade-hyprland = (pkgs: pkgs.writeShellScriptBin "upgrade" ''
'';
upgrade-hyprland = pkgs.writeShellScriptBin "upgrade" ''
cp flake.lock flake.lock.bak
nix flake lock --update-input hyprland
'');
refresh-hyprland = (pkgs: pkgs.writeShellScriptBin "refresh-hyprland" ''
rm -f ~/.config/hypr/hyprland.conf
rebuild test
cp ~/.config/hypr/hyprland.conf ~/.config/hypr/1
rm -f ~/.config/hypr/hyprland.conf
cp ~/.config/hypr/1 ~/.config/hypr/hyprland.conf
rm -f ~/.config/hypr/1
systemctl stop --user gammastep.service
'');
findModules = dir:
builtins.concatLists (builtins.attrValues (builtins.mapAttrs
(name: type:
if type == "regular" then
[{
name = builtins.elemAt (builtins.match "(.*)\\.nix" name) 0;
value = dir + "/${name}";
}]
else if (builtins.readDir (dir + "/${name}"))
? "default.nix" then [{
inherit name;
value = dir + "/${name}";
}] else
findModules (dir + "/${name}"))
(builtins.readDir dir)));
'';
in {
nixosModules = builtins.listToAttrs (findModules ./modules);
nixosProfiles = builtins.listToAttrs (findModules ./profiles);
nixosRoles = import ./roles;
# Generate system config for each of hardware configuration
nixosConfigurations = with nixpkgs.lib;
let
hosts = builtins.attrNames (builtins.readDir ./machines);
mkHost = name: nixosSystem {
system = builtins.readFile (./machines + "/${name}/system");
modules = [ (import (./machines + "/${name}")) { device = name; } ];
specialArgs = { inherit inputs; };
};
in (genAttrs hosts mkHost) // {
# NixOS-CT = nixpkgs-stable.lib.nixosSystem {
# system = builtins.readFile (./machines/NixOS-CT/system);
# modules = [ (import (./machines/NixOS-CT)) { device = "NixOS-CT"; } ];
# specialArgs = { inherit inputs; };
# };
devShell = channels.unstable.mkShell {
name = "aliases";
packages = [ rebuild update-vscode upgrade upgrade-hyprland ];
};
packages = {
Wayland-VM = nixos-generators.nixosGenerate {
system = builtins.readFile (./machines/Wayland-VM/system);
modules = [ (import (./machines/Wayland-VM)) ];
specialArgs = { inherit inputs; };
format = "vm";
};
Testing-VM = nixos-generators.nixosGenerate {
system = builtins.readFile (./machines/Testing-VM/system);
modules = [ (import (./machines/Testing-VM)) { device = "Testing-VM"; } ];
specialArgs = { inherit inputs; };
format = "vm";
};
legacyPackages.x86_64-linux =
(builtins.head (builtins.attrValues self.nixosConfigurations)).pkgs;
devShell.x86_64-linux = let
pkgs = self.legacyPackages.x86_64-linux;
in pkgs.mkShell {
nativeBuildInputs = [ (rebuild pkgs) (update-vscode pkgs) (upgrade pkgs) (upgrade-hyprland pkgs) (refresh-hyprland pkgs)];
};
};
nixosModules = builtins.listToAttrs (findModules ./modules);
nixosProfiles = builtins.listToAttrs (findModules ./profiles);
nixosRoles = import ./roles;
};
}