mirror of
https://github.com/srid/nixos-config.git
synced 2025-12-26 15:04:59 +08:00
Stop hardcoding my user name
This commit is contained in:
parent
dd0bf0c9a1
commit
0a8d28db1a
15 changed files with 34 additions and 27 deletions
|
|
@ -20,6 +20,7 @@ nix run
|
|||
- Edit `flake.nix` and
|
||||
- add your Linux's hostname in the `nixosConfigurations` set, as well as
|
||||
- update `people.myself` to your desired username.
|
||||
- put your SSH keys in `./nixos/takemessh`
|
||||
- Run `nix run`. That's it. Re-open your shell.
|
||||
- macOS:
|
||||
- Install Nix normally (multi-user)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ let
|
|||
type = lib.types.str;
|
||||
description = ''
|
||||
The name of the user that represents myself.
|
||||
|
||||
Admin user in all contexts.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
system = "aarch64-darwin";
|
||||
specialArgs = {
|
||||
inherit inputs system;
|
||||
flake = { inherit config; };
|
||||
rosettaPkgs = import inputs.nixpkgs { system = "x86_64-darwin"; };
|
||||
};
|
||||
modules = [
|
||||
|
|
|
|||
|
|
@ -34,7 +34,10 @@ in
|
|||
lib.mkLinuxSystem = extraModules: inputs.nixpkgs.lib.nixosSystem rec {
|
||||
system = "x86_64-linux";
|
||||
# Arguments to pass to all modules.
|
||||
specialArgs = { inherit system inputs; };
|
||||
specialArgs = {
|
||||
inherit system inputs;
|
||||
flake = { inherit config; };
|
||||
};
|
||||
modules = [
|
||||
self.nixosModules.default
|
||||
] ++ extraModules;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{ pkgs, ... }: {
|
||||
{ pkgs, config, ... }: {
|
||||
virtualisation.docker.enable = true;
|
||||
|
||||
users.users.srid = {
|
||||
users.users.${config.people.myself} = {
|
||||
extraGroups = [ "docker" ];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs, inputs, system, ... }:
|
||||
{ pkgs, inputs, system, flake, ... }:
|
||||
let
|
||||
emanote = inputs.emanote.outputs.defaultPackage.${system};
|
||||
in
|
||||
|
|
@ -12,9 +12,9 @@ in
|
|||
PORT = "7000";
|
||||
};
|
||||
serviceConfig = {
|
||||
User = "srid";
|
||||
User = flake.config.people.myself;
|
||||
Restart = "always";
|
||||
ExecStart = "${emanote}/bin/emanote -L /home/srid/Documents/Notes";
|
||||
ExecStart = "${emanote}/bin/emanote -L /home/${flake.config.people.myself}/Documents/Notes";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{ pkgs, ... }: {
|
||||
{ pkgs, flake, ... }: {
|
||||
virtualisation.lxd.enable = true;
|
||||
|
||||
users.users.srid = {
|
||||
users.users.${flake.config.people.myself} = {
|
||||
extraGroups = [ "lxd" ];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# TODO: GNOME support via https://extensions.gnome.org/extension/2645/brightness-control-using-ddcutil/
|
||||
|
||||
{ pkgs, ... }: {
|
||||
{ pkgs, flake, ... }: {
|
||||
# ddcutils requires i2c
|
||||
hardware.i2c.enable = true;
|
||||
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
security.sudo.extraRules = [
|
||||
{
|
||||
users = [ "srid" ];
|
||||
users = [ flake.config.people.myself ];
|
||||
commands = [
|
||||
{
|
||||
command = "${pkgs.ddcutil}/bin/ddcutil";
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
}
|
||||
];
|
||||
|
||||
users.users.srid = {
|
||||
users.users.${flake.config.people.myself} = {
|
||||
extraGroups = [ "i2c" ];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs, ... }:
|
||||
{ pkgs, flake, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
security.sudo.extraRules = [
|
||||
{
|
||||
users = [ "srid" ];
|
||||
users = [ flake.config.people.myself ];
|
||||
commands = [
|
||||
{
|
||||
command = "${pkgs.protonvpn-cli}/bin/protonvpn";
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
{ pkgs, inputs, ... }: {
|
||||
{ pkgs, inputs, flake, ... }: {
|
||||
# For no-prompt Ctrl+Shift+B in VSCode
|
||||
security.sudo.extraRules = [
|
||||
{
|
||||
users = [ "srid" ];
|
||||
users = [ flake.config.people.myself ];
|
||||
commands = [
|
||||
{
|
||||
command = "/run/current-system/sw/bin/nixos-rebuild";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs, ... }: {
|
||||
{ pkgs, flake, ... }: {
|
||||
|
||||
# Firewall
|
||||
networking.firewall.enable = true;
|
||||
|
|
@ -22,5 +22,5 @@
|
|||
};
|
||||
};
|
||||
nix.settings.allowed-users = [ "root" "@users" ];
|
||||
nix.settings.trusted-users = [ "root" "srid" ];
|
||||
nix.settings.trusted-users = [ "root" flake.config.people.myself ];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{ config, pkgs, lib, flake, ... }:
|
||||
|
||||
{
|
||||
# Let me login
|
||||
users.users = {
|
||||
root.openssh.authorizedKeys.keys = [ (builtins.readFile ./id_rsa.pub) ];
|
||||
srid.openssh.authorizedKeys.keys = [ (builtins.readFile ./id_rsa.pub) ];
|
||||
${flake.config.people.myself}.openssh.authorizedKeys.keys = [ (builtins.readFile ./id_rsa.pub) ];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{ pkgs, ... }: {
|
||||
{ pkgs, flake, ... }: {
|
||||
virtualisation.virtualbox.host = {
|
||||
enable = true;
|
||||
enableExtensionPack = true;
|
||||
};
|
||||
users.extraGroups.vboxusers.members = [ "srid" ];
|
||||
users.extraGroups.vboxusers.members = [ flake.config.people.myself ];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ config, pkgs, lib, inputs, system, rosettaPkgs, ... }:
|
||||
{ config, pkgs, lib, inputs, system, flake, rosettaPkgs, ... }:
|
||||
|
||||
{
|
||||
# List packages installed in system profile. To search by name, run:
|
||||
|
|
@ -63,7 +63,7 @@
|
|||
serviceConfig.ProgramArguments = [
|
||||
(lib.getExe inputs.emanote.packages.${system}.default)
|
||||
"-L"
|
||||
"/Users/srid/Keybase/Notes"
|
||||
"/Users/${flake.config.people.myself}/Keybase/Notes"
|
||||
"run"
|
||||
"-p"
|
||||
"7000"
|
||||
|
|
@ -74,8 +74,8 @@
|
|||
security.pam.enableSudoTouchIdAuth = true;
|
||||
|
||||
# For home-manager to work.
|
||||
users.users.srid.name = "srid";
|
||||
users.users.srid.home = "/Users/srid";
|
||||
users.users.${flake.config.people.myself}.name = flake.config.people.myself;
|
||||
users.users.${flake.config.people.myself}.home = "/Users/${flake.config.people.myself}";
|
||||
|
||||
# Use a custom configuration.nix location.
|
||||
# $ darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ config, pkgs, lib, inputs, modulesPath, ... }:
|
||||
{ config, pkgs, lib, inputs, modulesPath, flake, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
|
|
@ -114,7 +114,7 @@
|
|||
networking.firewall.checkReversePath = "loose"; # Tailscale recommends this
|
||||
|
||||
# Define a user account. Don't forget to set a password with ‘passwd’.
|
||||
users.users.srid = {
|
||||
users.users.${flake.config.people.myself} = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" "networkmanager" ];
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue