nixos-config/flake.nix

157 lines
5.3 KiB
Nix
Raw Normal View History

2020-08-04 01:46:48 +04:00
{
description = "System configuration";
inputs = {
2022-07-02 19:30:20 +03:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
2021-09-15 23:17:00 +03:00
nixpkgs-master.url = "github:nixos/nixpkgs/master";
2022-07-02 19:30:20 +03:00
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-22.05";
2022-08-24 18:33:53 +03:00
nixpkgs-custom.url = "github:nixos/nixpkgs/894bced14f7c66112d39233bcaeaaf708e077759";
2022-01-29 00:41:41 +03:00
nixpkgs-wayland = {
url = "github:nix-community/nixpkgs-wayland";
inputs.nixpkgs.follows = "nixpkgs";
};
2021-11-17 05:09:46 +03:00
nix.url = "github:nixos/nix";
2021-09-28 01:37:20 +03:00
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-04-22 02:15:29 +03:00
arkenfox-userjs = {
url = "github:arkenfox/user.js";
flake = false;
};
2021-09-15 23:17:00 +03:00
base16.url = "github:alukardbf/base16-nix";
2021-09-28 01:37:20 +03:00
base16-tokyonight-scheme = {
url = "github:alukardbf/base16-tokyonight-scheme";
2020-08-04 01:46:48 +04:00
flake = false;
};
2022-08-05 21:10:22 +03:00
comma = {
url = "github:nix-community/comma";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprland = {
url = "github:hyprwm/Hyprland";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-01-29 00:41:41 +03:00
nix-alien = {
url = "github:thiagokokada/nix-alien";
inputs.nixpkgs.follows = "nixpkgs";
2021-09-28 01:37:20 +03:00
};
nixpkgs-mozilla = {
url = "github:mozilla/nixpkgs-mozilla";
2020-11-28 05:07:18 +04:00
flake = false;
};
2022-04-22 02:15:29 +03:00
nur.url = github:nix-community/NUR;
2022-05-30 19:31:10 +03:00
polymc = {
url = "github:AquaVirus/PolyMC-Cracked";
inputs.nixpkgs.follows = "nixpkgs";
};
2021-09-28 01:37:20 +03:00
qbittorrent-ee = {
url = "github:c0re100/qBittorrent-Enhanced-Edition";
2020-08-07 23:27:49 +04:00
flake = false;
};
2021-06-16 05:30:04 +03:00
rycee = {
2021-09-15 23:17:00 +03:00
url = "gitlab:rycee/nur-expressions";
2021-06-16 05:30:04 +03:00
flake = false;
};
2021-10-30 21:04:53 +03:00
simple-nixos-mailserver = {
url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
inputs.nixpkgs.follows = "nixpkgs";
};
2021-11-12 05:30:35 +03:00
vscode-server-fixup = {
2022-05-18 00:24:47 +03:00
url = "github:MatthewCash/nixos-vscode-server";
2021-11-12 05:30:35 +03:00
inputs.nixpkgs.follows = "nixpkgs";
};
2021-09-28 01:37:20 +03:00
zsh-autosuggestions = {
url = "github:zsh-users/zsh-autosuggestions";
2021-09-15 15:33:45 +03:00
flake = false;
};
2021-09-28 01:37:20 +03:00
zsh-nix-shell = {
url = "github:chisui/zsh-nix-shell";
flake = false;
};
zsh-you-should-use = {
url = "github:MichaelAquilina/zsh-you-should-use";
2021-06-29 22:27:50 +03:00
flake = false;
};
2020-08-04 01:46:48 +04:00
};
2022-02-11 14:07:03 +03:00
outputs = { self, nixpkgs, nixpkgs-stable, ... }@inputs:
2021-09-15 23:17:00 +03:00
let
2021-10-25 23:41:09 +03:00
rebuild = (pkgs: 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 .
fi
'');
2022-08-05 21:10:22 +03:00
update-vscode = (pkgs: pkgs.writeShellScriptBin "update-vscode" ''
./scripts/vscode_update_extensions.sh > ./profiles/applications/vscode/extensions.nix
'');
upgrade = (pkgs: pkgs.writeShellScriptBin "upgrade" ''
cp flake.lock flake.lock.bak && nix flake update
update-vscode
'');
2022-08-23 16:13:51 +03:00
upgrade-hyprland = (pkgs: 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
'');
2021-09-15 23:17:00 +03:00
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);
2021-02-07 02:38:11 +03:00
2021-09-15 23:17:00 +03:00
nixosProfiles = builtins.listToAttrs (findModules ./profiles);
2020-08-04 01:46:48 +04:00
2021-09-15 23:17:00 +03:00
nixosRoles = import ./roles;
# Generate system config for each of hardware configuration
nixosConfigurations = with nixpkgs.lib;
let
hosts = builtins.attrNames (builtins.readDir ./machines);
2022-02-11 14:07:03 +03:00
mkHost = name: nixosSystem {
2021-10-25 00:37:34 +03:00
system = builtins.readFile (./machines + "/${name}/system");
2022-02-11 14:07:03 +03:00
modules = [ (import (./machines + "/${name}")) { device = name; } ];
specialArgs = { inherit inputs; };
};
in (genAttrs hosts mkHost) // {
2022-03-10 19:11:45 +03:00
# NixOS-CT = nixpkgs-stable.lib.nixosSystem {
# system = builtins.readFile (./machines/NixOS-CT/system);
# modules = [ (import (./machines/NixOS-CT)) { device = "NixOS-CT"; } ];
# specialArgs = { inherit inputs; };
# };
2022-02-11 14:07:03 +03:00
};
2020-08-15 19:36:16 +04:00
2021-09-15 23:17:00 +03:00
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 {
2022-08-23 16:13:51 +03:00
nativeBuildInputs = [ (rebuild pkgs) (update-vscode pkgs) (upgrade pkgs) (upgrade-hyprland pkgs) (refresh-hyprland pkgs)];
2021-10-25 23:41:09 +03:00
};
2020-08-15 19:36:16 +04:00
};
2020-08-04 01:46:48 +04:00
}