summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.lock21
-rw-r--r--flake.nix26
-rw-r--r--home-manager/common/home.nix13
-rw-r--r--home-manager/common/modules/git.nix15
-rw-r--r--nixos/common/configuration.nix7
-rw-r--r--nixos/common/modules/userdata.nix31
-rw-r--r--userdata.nix30
7 files changed, 104 insertions, 39 deletions
diff --git a/flake.lock b/flake.lock
index 9ec72ef..bd28315 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,5 +1,25 @@
{
"nodes": {
+ "home-manager": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1709764752,
+ "narHash": "sha256-+lM4J4JoJeiN8V+3WSWndPHj1pJ9Jc1UMikGbXLqCTk=",
+ "owner": "nix-community",
+ "repo": "home-manager",
+ "rev": "cf111d1a849ddfc38e9155be029519b0e2329615",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "repo": "home-manager",
+ "type": "github"
+ }
+ },
"nixpkgs": {
"locked": {
"lastModified": 1708296515,
@@ -34,6 +54,7 @@
},
"root": {
"inputs": {
+ "home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"sops-nix": "sops-nix"
}
diff --git a/flake.nix b/flake.nix
index 8c63e01..30bd680 100644
--- a/flake.nix
+++ b/flake.nix
@@ -8,14 +8,20 @@
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
+
+ home-manager = {
+ url = "github:nix-community/home-manager";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
};
- outputs = { self, nixpkgs, sops-nix }: let
+ outputs = { self, nixpkgs, sops-nix, home-manager }: let
lib = nixpkgs.lib;
- makeHost = host: system: lib.nixosSystem {
+ makeNixos = host: system: lib.nixosSystem {
inherit system;
modules = [
+ ./userdata.nix
{ networking.hostName = host; }
./nixos/${host}/configuration.nix
@@ -23,12 +29,20 @@
];
};
- makeX86 = hosts: lib.genAttrs hosts (
- host: makeHost host "x86_64-linux"
- );
+ makeHome = useType: system: home-manager.lib.homeManagerConfiguration {
+ pkgs = nixpkgs.legacyPackages.${system};
+ modules = [
+ ./userdata.nix
+ ./home-manager/${useType}/home.nix
+ ];
+ };
in
{
nixosConfigurations =
- makeX86 [ "cez" "kay" "lia" "fscusat" "dspace" ];
+ lib.genAttrs [ "cez" "kay" "lia" "fscusat" "dspace" ]
+ (host: makeNixos host "x86_64-linux");
+ homeConfigurations =
+ lib.genAttrs [ "common" ]
+ (host: makeHome host "x86_64-linux");
};
}
diff --git a/home-manager/common/home.nix b/home-manager/common/home.nix
new file mode 100644
index 0000000..b5886d4
--- /dev/null
+++ b/home-manager/common/home.nix
@@ -0,0 +1,13 @@
+{ config, ... }: let
+ username = config.userdata.user;
+in {
+ imports = [ ./modules/git.nix ];
+
+ programs.home-manager.enable = true;
+
+ home = {
+ inherit username;
+ stateVersion = "23.11";
+ homeDirectory = "/home/${config.home.username}";
+ };
+}
diff --git a/home-manager/common/modules/git.nix b/home-manager/common/modules/git.nix
new file mode 100644
index 0000000..df0407e
--- /dev/null
+++ b/home-manager/common/modules/git.nix
@@ -0,0 +1,15 @@
+{ config, ... }: let
+ userName = config.userdata.userFq;
+ userEmail = config.userdata.email;
+in {
+ programs.git = {
+ enable = true;
+ inherit userName;
+ inherit userEmail;
+
+ extraConfig = {
+ color.ui = "auto";
+ init.defaultBranch = "master";
+ };
+ };
+}
diff --git a/nixos/common/configuration.nix b/nixos/common/configuration.nix
index 5121cd6..6c4d29b 100644
--- a/nixos/common/configuration.nix
+++ b/nixos/common/configuration.nix
@@ -3,6 +3,7 @@
let
host = config.networking.hostName;
user = config.userdata.user;
+ email = config.userdata.email;
in
{
disabledModules = [
@@ -10,8 +11,6 @@ in
"services/mail/stalwart-mail.nix"
];
imports = [
- ./modules/userdata.nix
-
./modules/tmux.nix
./modules/dev.nix
@@ -32,6 +31,10 @@ in
};
users.users.${user} = {
+ uid = 1000;
+ isNormalUser = true;
+ description = email;
+
extraGroups = [ "wheel" ];
packages = with pkgs; [
bc
diff --git a/nixos/common/modules/userdata.nix b/nixos/common/modules/userdata.nix
deleted file mode 100644
index 00f0e13..0000000
--- a/nixos/common/modules/userdata.nix
+++ /dev/null
@@ -1,31 +0,0 @@
-{ config, lib, ... }:
-
-let
- inherit (lib) mkOption types mdDoc;
- cfg = config.userdata;
-in
-{
- options.userdata = {
- user = mkOption {
- type = types.str;
- default = "sinan";
- description = mdDoc "Owner's username";
- };
- domain = mkOption {
- type = types.str;
- default = "sinanmohd.com";
- description = mdDoc "Owner's domain";
- };
- email = mkOption {
- type = types.str;
- default = "sinan@${cfg.domain}";
- description = mdDoc "Owner's email";
- };
- };
-
- config.users.users.${cfg.user} = {
- uid = 1000;
- isNormalUser = true;
- description = cfg.email;
- };
-}
diff --git a/userdata.nix b/userdata.nix
new file mode 100644
index 0000000..ebcd1db
--- /dev/null
+++ b/userdata.nix
@@ -0,0 +1,30 @@
+{ config, lib, ... }:
+
+let
+ inherit (lib) mkOption types;
+ cfg = config.userdata;
+in
+{
+ options.userdata = {
+ user = mkOption {
+ type = types.str;
+ default = "sinan";
+ description = "Owner's username";
+ };
+ userFq = mkOption {
+ type = types.str;
+ default = "sinanmohd";
+ description = "Owner's fully qualified username";
+ };
+ domain = mkOption {
+ type = types.str;
+ default = "sinanmohd.com";
+ description = "Owner's domain";
+ };
+ email = mkOption {
+ type = types.str;
+ default = "${cfg.user}@${cfg.domain}";
+ description = "Owner's email";
+ };
+ };
+}