Skip to content

Commit

Permalink
Moving all nixos config into a flake
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKnarf committed Jul 12, 2024
1 parent 34a641e commit 1d161bf
Show file tree
Hide file tree
Showing 12 changed files with 458 additions and 64 deletions.
24 changes: 3 additions & 21 deletions os/nixos/Readme.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
# NixOS setup

## Machine config
NixOS setup using flakes.

```bash
$ sudo cat /etc/nixos/configuration.nix
{ config, pkgs, ... }:

{
imports = [
/home/knarf/configs/os/nixos/machine/configuration.nix
];
}
```
This way I can version control my config by having an empty configurations.nix that just imports the one in the repo.
After making changes simply run:
```bash
sudo nixos-rebuild switch
sudo nixos-rebuild switch --flake . # To rebuild the machine
home-manager switch --flake .
```

## home-manager
[home-manager guide](https://nix-community.github.io/home-manager/)
257 changes: 257 additions & 0 deletions os/nixos/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions os/nixos/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
description = "NixOS and Home-manager config";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};

hyprland = {
url = "git+https://github.com/hyprwm/Hyprland?submodules=1";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { nixpkgs, home-manager, hyprland, ... } @ inputs:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
system = "${system}";
config = {
allowUnfree = true;
};
};
user = "knarf";
in {
# Machine
nixosConfigurations."nixos" = nixpkgs.lib.nixosSystem {
inherit pkgs;
inherit system;

modules = [
./machine/configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.${user} = import ./home-manager/home.nix;
}
];

specialArgs = {inherit user;};
};

# Home manager
homeConfigurations."${user}" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;

modules = [
hyprland.homeManagerModules.default
./home-manager/home.nix
];

extraSpecialArgs = {inherit user;};
};
};
}
37 changes: 37 additions & 0 deletions os/nixos/home-manager/apps.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{ config, pkgs, ... }:

{
nixpkgs = {
config = {
allowUnfree = true;
allowUnfreePredicate = (_: true);
};
};

home.packages = [
# Browsers
pkgs.firefox

# Chat
pkgs.discord

# Multimedia
pkgs.spotify
pkgs.vlc
pkgs.audacity

# Streaming
pkgs.obs-studio

# 3D / CAD / Game engines
# pkgs.blender
# pkgs.freecad
pkgs.openscad
pkgs.godot_4

# Other
pkgs.webtorrent_desktop
pkgs.obsidian
];

}
3 changes: 2 additions & 1 deletion os/nixos/home-manager/env.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
pkgs.helix

# Programming
pkgs.fnm # Fast and simple Node.js version manager
pkgs.nodejs_20
pkgs.corepack
pkgs.bun
pkgs.rustup
pkgs.go
Expand Down
Loading

0 comments on commit 1d161bf

Please sign in to comment.