configuration.nix/flake.nix
Jalil David Salamé Messina 63f529704d
All checks were successful
/ check (push) Successful in 28s
/ build (docs) (push) Successful in 2s
/ build (nixosConfigurations.vm.config.system.build.toplevel) (push) Successful in 23s
/ build (nvim) (push) Successful in 14s
[fix] nixvim: rollback to nixpkgs-stable
See [nixvim/#1699][1] for context.

[1]: <https://github.com/nix-community/nixvim/issues/1699>
2024-06-14 23:55:46 +02:00

263 lines
7.2 KiB
Nix

# 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 = {
nixpkgs.url = "nixpkgs/nixos-24.05";
unstable.url = "nixpkgs/nixos-unstable";
# Software
jpassmenu = {
url = "github:jalil-salame/jpassmenu";
inputs.nixpkgs.follows = "nixpkgs";
};
audiomenu = {
url = "github:jalil-salame/audiomenu";
inputs.nixpkgs.follows = "nixpkgs";
};
# Lix
lix = {
url = "https://git.lix.systems/lix-project/lix/archive/main.tar.gz";
flake = false;
};
lix-module = {
url = "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz";
inputs = {
lix.follows = "lix";
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
# Modules
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-hardware.url = "github:NixOS/nixos-hardware";
# FIXME: pin to 24.05 when avalialble
stylix = {
url = "github:danth/stylix/release-24.05";
inputs = {
nixpkgs.follows = "nixpkgs";
home-manager.follows = "home-manager";
};
};
nixvim = {
url = "github:nix-community/nixvim";
inputs = {
# Disable until fixed upstream: https://github.com/nix-community/nixvim/issues/1699
# nixpkgs.follows = "unstable";
nixpkgs.follows = "nixpkgs";
devshell.follows = "devshell";
nix-darwin.follows = ""; # disable MacOS stuff
home-manager.follows = "home-manager";
flake-compat.follows = "stylix/flake-compat";
};
};
# For deduplication
systems.url = "github:nix-systems/default";
flake-utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};
devshell = {
url = "github:numtide/devshell";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
};
# Flake outputs that other flakes can use
outputs = {
self,
nixpkgs,
unstable,
stylix,
home-manager,
nixos-hardware,
jpassmenu,
audiomenu,
nixvim,
lix-module,
...
}: 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;
pkgs = import nixpkgs {inherit system;};
}
);
overlays = builtins.attrValues self.overlays;
in {
checks = forEachSupportedSystem (
{
pkgs,
system,
}: let
src = builtins.path {
path = ./.;
name = "configuration.nix";
};
in {
nvim = nixvim.lib.${system}.check.mkTestDerivationFromNixvimModule {
pkgs = import nixpkgs {inherit system overlays;};
module = ./nvim/nixvim.nix;
};
fmt = pkgs.callPackage ./fmt.nix {inherit src;};
lint = pkgs.callPackage ./lint.nix {inherit src;};
typos = pkgs.callPackage ./lint.nix {inherit src;};
}
);
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;
};
}
);
# Provide necessary overlays
overlays = {
nixvim = nixvim.overlays.default;
jpassmenu = jpassmenu.overlays.default;
audiomenu = audiomenu.overlays.default;
unstable = final: prev: {
inherit
(unstable.legacyPackages.${prev.system})
gitoxide
jujutsu
wezterm
;
unstable = unstable.legacyPackages.${prev.system};
};
};
# 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";
isNormalUser = true;
extraGroups = [
"wheel"
"video"
"networkmanager"
];
};
home-manager.users.jdoe = {
home = {
username = "jdoe";
homeDirectory = "/home/jdoe";
};
jhome = {
enable = true;
gui.enable = true;
dev.rust.enable = true;
};
};
nix.registry.nixpkgs.flake = nixpkgs;
jconfig = {
enable = true;
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
]
++ nixpkgs.lib.optional (lix-module != null) lix-module.nixosModules.default;
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
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
];
QEMU_OPTS_WL = "--enable-kvm -smp 4 -device virtio-gpu-rutabaga,gfxstream-vulkan=on,cross-domain=on,hostmem=2G,wsi=headless";
};
}
);
};
}