configuration.nix/flake.nix

231 lines
6.6 KiB
Nix
Raw Normal View History

2024-01-14 17:33:16 +01:00
# This flake was initially generated by fh, the CLI for FlakeHub (version 0.1.9)
{
# A helpful description of your flake
description = "My NixOS configuration";
# Flake inputs
inputs.stylix.url = "github:jalil-salame/stylix/fallback-fonts-v2";
2024-01-14 17:33:16 +01:00
inputs.stylix.inputs.nixpkgs.follows = "nixpkgs";
inputs.stylix.inputs.home-manager.follows = "home-manager";
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
inputs.jpassmenu.url = "github:jalil-salame/jpassmenu";
inputs.jpassmenu.inputs.nixpkgs.follows = "nixpkgs";
inputs.audiomenu.url = "github:jalil-salame/audiomenu";
inputs.audiomenu.inputs.nixpkgs.follows = "nixpkgs";
2024-03-02 20:48:34 +01:00
inputs.nixvim.url = "github:nix-community/nixvim";
inputs.nixvim.inputs.nixpkgs.follows = "nixpkgs";
inputs.nixvim.inputs.home-manager.follows = "home-manager";
# disable MacOS stuff
inputs.nixvim.inputs.nix-darwin.follows = "";
# WARN: Flakehub is outdated (39 days out of date)
# inputs.home-manager.url = "https://flakehub.com/f/nix-community/home-manager/0.1.*.tar.gz";
inputs.home-manager.url = "github:nix-community/home-manager";
2024-01-14 17:33:16 +01:00
inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs";
inputs.nixos-hardware.url = "github:NixOS/nixos-hardware";
2024-01-14 17:33:16 +01:00
inputs.neovim-flake.url = "github:neovim/neovim?dir=contrib";
inputs.neovim-flake.inputs.nixpkgs.follows = "nixpkgs";
2024-01-15 12:57:59 +01:00
2024-01-14 17:33:16 +01:00
# Flake outputs that other flakes can use
2024-05-04 20:57:33 +02:00
outputs = {
self,
nixpkgs,
stylix,
home-manager,
nixos-hardware,
jpassmenu,
audiomenu,
nixvim,
neovim-flake,
}: let
inherit (nixpkgs) lib;
# Helpers for producing system-specific outputs
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
];
forEachSupportedSystem = f:
nixpkgs.lib.genAttrs supportedSystems (
system:
f {
inherit system;
2024-05-04 20:57:33 +02:00
pkgs = import nixpkgs {inherit system;};
}
);
2024-05-04 20:57:33 +02:00
overlays = builtins.attrValues self.overlays;
in {
checks = forEachSupportedSystem (
{
pkgs,
system,
}: let
src = builtins.path {
path = ./.;
name = "configuration.nix";
};
in {
2024-05-04 20:57:33 +02:00
nvim = nixvim.lib.${system}.check.mkTestDerivationFromNixvimModule {
pkgs = import nixpkgs {inherit system overlays;};
module = ./nvim/nixvim.nix;
};
formatting = let
fmt = pkgs.lib.getExe self.formatter.${system};
in
pkgs.stdenvNoCC.mkDerivation {
name = "nix-formatting-check";
dontUnpack = true;
dontBuild = true;
doCheck = true;
checkPhase = "${fmt} --check ${src}";
installPhase = "mkdir $out";
};
typos = let
typos = pkgs.lib.getExe pkgs.typos;
in
pkgs.stdenvNoCC.mkDerivation {
name = "typos-check";
dontUnpack = true;
dontBuild = true;
doCheck = true;
checkPhase = "${typos} --color=always ${src}";
installPhase = "mkdir $out";
};
2024-05-04 20:57:33 +02:00
}
);
packages = forEachSupportedSystem (
{
pkgs,
system,
}: {
inherit
(import ./docs {inherit pkgs lib;})
docs
nixos-markdown
nvim-markdown
home-markdown
;
# Nvim standalone module
nvim = nixvim.legacyPackages.${system}.makeNixvimWithModule {
pkgs = import nixpkgs {inherit system overlays;};
module = ./nvim/nixvim.nix;
};
2024-05-04 20:57:33 +02:00
}
);
# Provide necessary overlays
overlays = {
nixvim = nixvim.overlays.default;
neovim-nightly = neovim-flake.overlay;
jpassmenu = jpassmenu.overlays.default;
audiomenu = audiomenu.overlays.default;
};
2024-05-04 20:57:33 +02:00
# Nix files formatter (run `nix fmt`)
formatter = forEachSupportedSystem ({pkgs, ...}: pkgs.alejandra);
# Example vm configuration
nixosConfigurations.vm = let
system = "x86_64-linux";
config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) ["steam-original"];
pkgs = import nixpkgs {inherit system overlays config;};
in
lib.nixosSystem {
inherit system pkgs;
modules = [
self.nixosModules.vm # import vm module
{
time.timeZone = "Europe/Berlin";
i18n.defaultLocale = "en_US.UTF-8";
users.users.jdoe.password = "example";
users.users.jdoe.isNormalUser = true;
users.users.jdoe.extraGroups = [
"wheel"
"video"
"networkmanager"
];
2024-05-04 20:57:33 +02:00
home-manager.users.jdoe = {
home.username = "jdoe";
home.homeDirectory = "/home/jdoe";
jhome.enable = true;
jhome.gui.enable = true;
jhome.dev.rust.enable = true;
};
nix.registry.nixpkgs.flake = nixpkgs;
2024-01-15 12:57:59 +01:00
2024-05-04 20:57:33 +02:00
jconfig.enable = true;
jconfig.gui.enable = true;
}
];
};
nixosModules = let
nvim-config.imports = [
nixvim.homeManagerModules.nixvim
./nvim
];
overlays = builtins.attrValues self.overlays;
homeManagerModuleSandalone = import ./home {inherit overlays nvim-config stylix;};
homeManagerModuleNixOS = import ./home {inherit overlays nvim-config;};
nixosModule = {
imports = [
(import ./system {inherit stylix;})
home-manager.nixosModules.home-manager
];
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.sharedModules = [homeManagerModuleNixOS];
# Pin nixpkgs
nix.registry.nixpkgs.flake = nixpkgs;
};
machines = [
"capricorn"
"gemini"
"libra"
"vm"
];
mkMachine = hostname: {
imports = [
nixosModule
(import (./machines + "/${hostname}") {inherit nixos-hardware;})
];
home-manager.sharedModules = [{jhome.hostName = hostname;}];
};
machineModules = lib.genAttrs machines mkMachine;
in
{
default = nixosModule;
inherit nixosModule homeManagerModuleNixOS homeManagerModuleSandalone;
}
// machineModules;
devShells = forEachSupportedSystem (
{
pkgs,
system,
}: {
default = pkgs.mkShell {
buildInputs = with pkgs; [
just
self.packages.${system}.nvim
];
2024-05-04 20:57:33 +02:00
QEMU_OPTS_WL = "-smp 4 -device virtio-gpu-rutabaga,gfxstream-vulkan=on,cross-domain=on,hostmem=2G,wsi=headless";
};
}
);
};
2024-01-14 17:33:16 +01:00
}