Skip to content

Commit

Permalink
WIP: NixOS
Browse files Browse the repository at this point in the history
  • Loading branch information
srid committed Oct 3, 2024
1 parent 22ed18c commit 2252c71
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- main
- update_flake_lock_action
- nixos
pull_request:
jobs:
nix:
Expand Down
34 changes: 34 additions & 0 deletions configurations/nixos/example.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See /modules/nixos/* for actual settings
# This file is just *top-level* configuration.
{ flake, ... }:

let
inherit (flake) inputs;
inherit (inputs) self;
in
{
imports = [
self.nixosModules.default
];

# These are normally in hardware-configuration.nix
boot.loader.grub.device = "nodev";
fileSystems."/" = { device = "/dev/disk/by-label/nixos"; fsType = "btrfs"; };

nixpkgs.hostPlatform = "aarch64-linux";
networking.hostName = "example";

# For home-manager to work.
# https://github.com/nix-community/home-manager/issues/4026#issuecomment-1565487545
# users.users."runner".home = "/Users/runner";
users.users."runner".isNormalUser = true;

# Enable home-manager for "runner" user
home-manager.users."runner" = {
imports = [ (self + /configurations/home/runner.nix) ];
};

# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = "24.05";
}
33 changes: 33 additions & 0 deletions modules/flake-parts/template.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
darwinOnly =
hasInfix "configurations/darwin" path
|| hasInfix "modules/darwin" path;
nixosOnly =
hasInfix "configurations/nixos" path
|| hasInfix "modules/nixos" path;
alwaysExclude =
hasSuffix "LICENSE" path
|| hasSuffix "README.md" path
Expand Down Expand Up @@ -52,6 +55,25 @@
};
};

nixos = let parent = templates.default; in {
description = mkDescription "NixOS";
welcomeText = ''
You have just created a nixos-unified-template flake.nix using NixOS.
- Edit `./modules/nixos/*.nix` to customize your configuration.
- Run `cp /etc/nixos/*.nix .` to import your existing configuration.
- Run `nix run` to apply the configuration.
Enjoy!
'';
path = builtins.path {
path = parent.path;
filter = path: _:
!(filters path).nixosOnly;
};

};

nix-darwin = let parent = templates.default; in {
description = mkDescription "nix-darwin";
welcomeText = ''
Expand Down Expand Up @@ -111,6 +133,17 @@
];
};

nixos = {
template = templates.nixos;
params = [
{
name = "hostname";
description = "Your system hostname as shown by `hostname -s`";
placeholder = "example";
}
] ++ om.templates.home.params;
};

darwin = {
template = templates.nix-darwin;
params = [
Expand Down
11 changes: 11 additions & 0 deletions modules/nixos/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is your nix-darwin configuration.
# For home configuration, see /modules/home/*
{ flake, pkgs, lib, ... }:

let
inherit (flake) inputs;
inherit (inputs) self;
in
{
services.openssh.enable = true;
}

0 comments on commit 2252c71

Please sign in to comment.