Skip to content

Commit

Permalink
feat(nix): import my nixos configs
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Nov 17, 2023
1 parent e2e00fb commit d236dcc
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 188 deletions.
3 changes: 3 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ tasks:
tmux:
cmds:
- tmux source ~/.config/tmux/tmux.conf
apply_nixos:
cmds:
- sudo nixos-rebuild switch -I nixos-config=./machines/{{ .HOSTNAME }}.nix
apply_darwin:
status:
- "test $(uname -s) -ne Darwin"
Expand Down
160 changes: 3 additions & 157 deletions machines/darkstar.nix
Original file line number Diff line number Diff line change
@@ -1,81 +1,24 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, modulesPath, ... }:
let
unstableTarball =
fetchTarball
"https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz";
in

{ ... }:
{
imports =
[
<home-manager/nixos>
./hardware/darkstar.nix
(modulesPath + "/profiles/qemu-guest.nix")
./shared.nix
/etc/nixos/hardware-configuration.nix
];

# Bootloader.
boot.loader.grub.enable = true;
boot.loader.grub.device = "/dev/sda";
boot.loader.grub.useOSProber = true;

networking.hostName = "darkstar"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.

# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

# Enable networking
networking.networkmanager.enable = true;

# Set your time zone.
time.timeZone = "America/Sao_Paulo";

# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";

i18n.extraLocaleSettings = {
LC_ADDRESS = "pt_BR.UTF-8";
LC_IDENTIFICATION = "pt_BR.UTF-8";
LC_MEASUREMENT = "pt_BR.UTF-8";
LC_MONETARY = "pt_BR.UTF-8";
LC_NAME = "pt_BR.UTF-8";
LC_NUMERIC = "pt_BR.UTF-8";
LC_PAPER = "pt_BR.UTF-8";
LC_TELEPHONE = "pt_BR.UTF-8";
LC_TIME = "pt_BR.UTF-8";
};

# Enable the X11 windowing system.
services.xserver.enable = true;

# Enable the GNOME Desktop Environment.
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;

# Configure keymap in X11
services.xserver = {
layout = "us";
xkbVariant = "";
};

security.sudo.extraRules = [
{
users = [ "carlos" ];
commands = [
{
command = "ALL";
options = [ "NOPASSWD" ];
}
];
}
];


# Enable CUPS to print documents.
services.printing.enable = true;

Expand All @@ -99,19 +42,6 @@ in
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;

# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.carlos = {
isNormalUser = true;
description = "carlos";
extraGroups = [ "networkmanager" "wheel" ];
shell = pkgs.fish;
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILxWe2rXKoiO6W14LYPVfJKzRfJ1f3Jhzxrgjc/D4tU7"
];
packages = with pkgs; [
];
};

# Enable automatic login for the user.
services.xserver.displayManager.autoLogin.enable = true;
services.xserver.displayManager.autoLogin.user = "carlos";
Expand All @@ -120,86 +50,6 @@ in
systemd.services."getty@tty1".enable = false;
systemd.services."autovt@tty1".enable = false;

# Allow unfree packages
nixpkgs.config = {
allowUnfree = true;
packageOverrides = pkgs: {
unstable = import unstableTarball {
config = config.nixpkgs.config;
};
};
};


# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
neovim
wget
curl
unzip
];

# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
programs.fish.enable = true;

# List services that you want to enable:

# Enable the OpenSSH daemon.
services.openssh.enable = true;
services.cron.enable = true;
services.avahi = {
enable = true;
nssmdns = true;
publish = {
enable = true;
domain = true;
addresses = true;
};
};

services.tailscale = {
enable = true;
package = pkgs.unstable.tailscale;
};

# create a oneshot job to authenticate to Tailscale
systemd.services.tailscale-autoconnect = {
description = "Automatic connection to Tailscale";

# make sure tailscale is running before trying to connect to tailscale
after = [ "network-pre.target" "tailscale.service" ];
wants = [ "network-pre.target" "tailscale.service" ];
wantedBy = [ "multi-user.target" ];

# set this service as a oneshot job
serviceConfig.Type = "oneshot";

# have the job run this shell script
script = with pkgs; ''
# wait for tailscaled to settle
sleep 2
# check if we are already authenticated to tailscale
status="$(${tailscale}/bin/tailscale status -json | ${jq}/bin/jq -r .BackendState)"
if [ $status = "Running" ]; then # if so, then do nothing
exit 0
fi
# otherwise authenticate with tailscale
${tailscale}/bin/tailscale up -authkey tskey-auth-kyAnaY2CNTRL-ZyUQdnUtaTSD9xyvF3bQXSDZrk7xHERvW
'';
};




# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
Expand All @@ -213,9 +63,5 @@ in
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.05"; # Did you read the comment?

# virtualisation.qemu.guestAgent.enable = true;
}



31 changes: 0 additions & 31 deletions machines/hardware/darkstar.nix

This file was deleted.

70 changes: 70 additions & 0 deletions machines/media.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ pkgs, ... }:
{
imports =
[
./shared.nix
/etc/nixos/hardware-configuration.nix
];

networking.hostName = "media"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.

users.users.carlos.packages = with pkgs; [
unrar
];

services.jellyfin = {
enable = true;
openFirewall = true;
group = "wheel";
user = "carlos";
package = pkgs.unstable.jellyfin;
};
services.sonarr = {
enable = true;
openFirewall = true;
group = "wheel";
user = "carlos";
package = pkgs.unstable.sonarr;
};
services.radarr = {
enable = true;
openFirewall = true;
group = "wheel";
user = "carlos";
package = pkgs.unstable.radarr;
};
services.jackett = {
enable = true;
openFirewall = true;
group = "wheel";
user = "carlos";
package = pkgs.unstable.jackett;
};
services.transmission = {
enable = true;
openFirewall = true;
openRPCPort = true;
group = "wheel";
user = "carlos";
settings = {
rpc-bind-address = "0.0.0.0";
rpc-whitelist = "127.0.0.1,192.168.1.*";
download-dir = "/home/carlos/media";
incomplete-dir = "/home/carlos/media";
};
};

# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.05"; # Did you read the comment?
}

0 comments on commit d236dcc

Please sign in to comment.