nix-config/flake.in.nix
2024-05-28 04:08:06 -04:00

144 lines
4.5 KiB
Nix

{
inputs = let
mkCustomUrl = url: {inherit url;};
mkInput = url: {url = "github:${url}";};
mkFollowingNixpkgs = url: {
url = "github:${url}";
inputs.nixpkgs.follows = "nixpkgs";
};
mkFollowing = url: input: {
url = "github:${url}";
inputs.${input}.follows = input;
};
mkWithSubmodules = url: {
inherit url;
submodules = true;
type = "git";
};
in {
agenix = mkInput "ryantm/agenix";
catppuccin = mkInput "catppuccin/nix";
chaotic = mkInput "chaotic-cx/nyx/nyxpkgs-unstable";
hyprland = mkWithSubmodules "https://github.com/hyprwm/Hyprland";
hyprland-plugins = mkFollowing "hyprwm/hyprland-plugins" "hyprland";
impermanence = mkInput "nix-community/impermanence";
nix-colors = mkInput "Misterio77/nix-colors";
nixpkgs = mkInput "NixOS/nixpkgs/nixos-unstable";
nix-super = mkCustomUrl "git+https://git.privatevoid.net/max/nix-super.git";
nixvim = mkInput "pupbrained/nixvim";
schizofox = mkInput "schizofox/schizofox";
sops-nix = mkInput "Mic92/sops-nix";
treefmt-nix = mkInput "numtide/treefmt-nix";
home-manager = mkFollowingNixpkgs "nix-community/home-manager";
nix-index-database = mkFollowingNixpkgs "nix-community/nix-index-database";
snowfall-flake = mkFollowingNixpkgs "snowfallorg/flake";
snowfall-lib = mkFollowingNixpkgs "snowfallorg/lib/dev";
};
outputs = {...} @ inputs:
with inputs; let
pkgs = import nixpkgs {inherit system;};
system = "x86_64-linux";
in
snowfall-lib.mkFlake {
inherit inputs;
src = ./.;
formatter.${system} = treefmt-nix.lib.mkWrapper pkgs {
projectRootFile = "flake.nix";
programs = {
alejandra.enable = true;
deadnix.enable = true;
};
};
overlays = [
snowfall-flake.overlays.default
(_final: prev: {
nixSuper = nix-super.packages.${system}.default;
ccacheWrapper = prev.ccacheWrapper.override {
extraConfig = ''
export CCACHE_COMPRESS=1
export CCACHE_DIR="${config.programs.ccache.cacheDir}"
export CCACHE_UMASK=007
if [ ! -d "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' does not exist"
echo "Please create it with:"
echo " sudo mkdir -m0770 '$CCACHE_DIR'"
echo " sudo chown root:nixbld '$CCACHE_DIR'"
echo "====="
exit 1
fi
if [ ! -w "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)"
echo "Please verify its access permissions"
echo "====="
exit 1
fi
'';
};
picom = prev.picom.overrideAttrs {
src = prev.fetchFromGitHub {
owner = "yshui";
repo = "picom";
rev = "94faacbd4ac917cca5abac3ac5c539f5fe1dc61d";
hash = "sha256-KfMy8lV3FMS+AWDozlpPRkXX1eZCWsj39Y5T8q+c9Bs=";
fetchSubmodules = true;
};
};
})
];
channels-config = {
allowAliases = true;
allowUnfree = true;
allowUnsupportedSystem = true;
cudaSupport = true;
permittedInsecurePackages = ["freeimage-unstable-2021-11-01"];
home-manager.useGlobalPkgs = true;
};
homes.modules = [
catppuccin.homeManagerModules.catppuccin
chaotic.homeManagerModules.default
hyprland.homeManagerModules.default
nix-colors.homeManagerModules.default
nix-index-database.hmModules.nix-index
schizofox.homeManagerModules.default
];
systems.modules.nixos = [
agenix.nixosModules.default
catppuccin.nixosModules.catppuccin
chaotic.nixosModules.default
impermanence.nixosModules.impermanence
];
devShells.${system}.default = with pkgs;
mkShellNoCC {
packages = [
alejandra
git
nvfetcher
statix
(writeScriptBin "build" ''
nix fmt
nh os switch . -- --impure
nh home switch
'')
(writeScriptBin "up" "nix flake update")
];
};
};
}