mirror of
https://github.com/ItsDrike/nixdots
synced 2024-11-10 02:19:41 +00:00
Initial commit
This commit is contained in:
commit
ed50178c17
105
configuration.nix
Normal file
105
configuration.nix
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
# 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, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports =
|
||||||
|
[ # Include the results of the hardware scan.
|
||||||
|
./hardware-configuration.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
# Bootloader.
|
||||||
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
|
|
||||||
|
networking.hostName = "nixos"; # 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 = "Europe/Bratislava";
|
||||||
|
|
||||||
|
# Select internationalisation properties.
|
||||||
|
i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
|
||||||
|
i18n.extraLocaleSettings = {
|
||||||
|
LC_ADDRESS = "sk_SK.UTF-8";
|
||||||
|
LC_IDENTIFICATION = "sk_SK.UTF-8";
|
||||||
|
LC_MEASUREMENT = "sk_SK.UTF-8";
|
||||||
|
LC_MONETARY = "sk_SK.UTF-8";
|
||||||
|
LC_NAME = "sk_SK.UTF-8";
|
||||||
|
LC_NUMERIC = "sk_SK.UTF-8";
|
||||||
|
LC_PAPER = "sk_SK.UTF-8";
|
||||||
|
LC_TELEPHONE = "sk_SK.UTF-8";
|
||||||
|
LC_TIME = "sk_SK.UTF-8";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Configure keymap in X11
|
||||||
|
services.xserver = {
|
||||||
|
layout = "us";
|
||||||
|
xkbVariant = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Define a user account. Don't forget to set a password with ‘passwd’.
|
||||||
|
users.users.itsdrike = {
|
||||||
|
isNormalUser = true;
|
||||||
|
description = "ItsDrike";
|
||||||
|
extraGroups = [ "networkmanager" "wheel" ];
|
||||||
|
packages = with pkgs; [];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Allow unfree packages
|
||||||
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
|
# List packages installed in system profile. To search, run:
|
||||||
|
# $ nix search wget
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
vim
|
||||||
|
git
|
||||||
|
# vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
|
||||||
|
# wget
|
||||||
|
];
|
||||||
|
|
||||||
|
# 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;
|
||||||
|
# };
|
||||||
|
|
||||||
|
# List services that you want to enable:
|
||||||
|
|
||||||
|
# Enable the OpenSSH daemon.
|
||||||
|
# services.openssh.enable = true;
|
||||||
|
|
||||||
|
# Open ports in the firewall.
|
||||||
|
# networking.firewall.allowedTCPPorts = [ ... ];
|
||||||
|
# networking.firewall.allowedUDPPorts = [ ... ];
|
||||||
|
# Or disable the firewall altogether.
|
||||||
|
# networking.firewall.enable = false;
|
||||||
|
|
||||||
|
# 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.11"; # Did you read the comment?
|
||||||
|
|
||||||
|
nix = {
|
||||||
|
package = pkgs.nixUnstable;
|
||||||
|
extraOptions = ''
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
17
flake.nix
Normal file
17
flake.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
description = "ItsDrike's NixOS configuration";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
# the version here should match your system.stateVersion in configuration.nix
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, ...} @ inputs: {
|
||||||
|
nixosConfigurations = {
|
||||||
|
nixos = nixpkgs.lib.nixosSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
modules = [ ./configuration.nix ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
146
guides/installation.md
Normal file
146
guides/installation.md
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
This is a full NixOS installation guide, from live cd to a working OS.
|
||||||
|
Once done, you will be left with a complete system, that uses my configuration.
|
||||||
|
|
||||||
|
This installation will push to use flakes out of the box, configuration.nix will
|
||||||
|
only be needed to add support for flakes and rebuild.
|
||||||
|
|
||||||
|
## Live ISO
|
||||||
|
|
||||||
|
This assumes you've chosen one of the ISO images with a graphical installer, and
|
||||||
|
followed though with the installation, getting you to a basic NixOS installation.
|
||||||
|
|
||||||
|
During this installation, make sure you allow non-free programs, and in the desktop environment selection, pick the option without any DE, we'll get to install that ourselves.
|
||||||
|
|
||||||
|
## Set up configuration.nix
|
||||||
|
|
||||||
|
First thing you'll need to do is to make your useer account own the
|
||||||
|
`/etc/nixos` directory. You'll want to do this to allow you to easily manage
|
||||||
|
your config with git (which is a requirement when using flakes). You can use
|
||||||
|
system wide git, however it is much more convenient to just leave it to the
|
||||||
|
user, as you'll have your git configuration there.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd /etc/nixos
|
||||||
|
sudo chmod -R itsdrike:users .
|
||||||
|
```
|
||||||
|
|
||||||
|
Out of the box, NixOS only comes with `nano` editor, so we'll have to use that to edit the `configuration.nix` for the first time.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
nano configuration.nix
|
||||||
|
```
|
||||||
|
|
||||||
|
In there, change the `environment.systemPackages = with pkgs; [];` like, and include `git` and `vim`.
|
||||||
|
|
||||||
|
After that, let's enable flakes, by adding the following at the end of your `configuration.nix` (but still within the function body - before the last `}`):
|
||||||
|
|
||||||
|
```nix
|
||||||
|
nix = {
|
||||||
|
package = pkgs.nixUnstable;
|
||||||
|
extraOptions = ''
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
''
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can save the changes and rebuild the system:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo nixos-rebuild switch
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set up flakes
|
||||||
|
|
||||||
|
Now, since a git repository is required for flakes, let's set up git:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git config --global user.email "itsdrike@protonmail.com"
|
||||||
|
git config --global user.name "ItsDrike"
|
||||||
|
```
|
||||||
|
|
||||||
|
Now we have 2 options, the first one I'll show will set up my configuration
|
||||||
|
from this repository. Once done, you will have your system set up in the same
|
||||||
|
way that I do. In the second option, I will go over a basic setup to create
|
||||||
|
your own flake.
|
||||||
|
|
||||||
|
## Set up with my configuration
|
||||||
|
|
||||||
|
Finally, we're ready to migrate to flakes. At this point, you can simply pull this repository
|
||||||
|
to the `/etc/nixos` directory, to get my setup, like so:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git init
|
||||||
|
git remote add origin https://github.com/ItsDrike/nixdots
|
||||||
|
git branch -C main
|
||||||
|
git pull
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create your own custom flake
|
||||||
|
|
||||||
|
Initialize an empty git repository:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git init
|
||||||
|
```
|
||||||
|
|
||||||
|
Create a very basic `/etc/nixos/flake.nix`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
{
|
||||||
|
description = "ItsDrike's NixOS configuration";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
# the version here should match your system.stateVersion in configuration.nix
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, ...} @ inputs: {
|
||||||
|
nixosConfigurations = {
|
||||||
|
nixos = nixpkgs.lib.nixosSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
modules = [ ./configuration.nix ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This flake will still rely on your `configuration.nix`, we will eventually get
|
||||||
|
to a config which does not need this file, but to make starting out with flakes
|
||||||
|
simple, we'll do it in this way for now.
|
||||||
|
|
||||||
|
Let's add things to git!
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git add flake.nix
|
||||||
|
git add configuration.nix
|
||||||
|
git add hardware-configuration.nix
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can run `sudo nixos-rebuild switch`. Yay, you're now using NixOS in flakes mode!
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> If you run the `sudo nixos-rebuild switch` command before adding all of these
|
||||||
|
> files to git, you will get an error, so it really is a requirement to have
|
||||||
|
> your configuration in a git repository when you're using flakes.
|
||||||
|
|
||||||
|
You can notice that this also created a `flake.lock` file, containing the exact
|
||||||
|
versions of all of the packages you're using. You can (but don't have to) add
|
||||||
|
this file to git too: `git add flake.lock`.
|
||||||
|
|
||||||
|
Let's make a commit:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git commit -a -m "Initial commit"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Updating
|
||||||
|
|
||||||
|
Over time, to update the software that's installed on your machine, you can use
|
||||||
|
`nix flake update`, to update your `flake.lock` file, and then `nixos-rebuild
|
||||||
|
switch`, to get switch your system to the new dependencies.
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> This replaces the legacy (non-flake) regime's command: `nixos-rebuild switch --upgrade`
|
37
hardware-configuration.nix
Normal file
37
hardware-configuration.nix
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||||
|
# and may be overwritten by future invocations. Please make changes
|
||||||
|
# to /etc/nixos/configuration.nix instead.
|
||||||
|
{ config, lib, pkgs, modulesPath, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ];
|
||||||
|
|
||||||
|
boot.initrd.availableKernelModules = [ "ata_piix" "ohci_pci" "ehci_pci" "ahci" "sd_mod" "sr_mod" ];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
fileSystems."/" =
|
||||||
|
{ device = "/dev/disk/by-uuid/86d578b1-fd70-4f72-918d-44d921fe8a73";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [ "subvol=@" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/boot" =
|
||||||
|
{ device = "/dev/disk/by-uuid/7636-1642";
|
||||||
|
fsType = "vfat";
|
||||||
|
};
|
||||||
|
|
||||||
|
swapDevices = [ ];
|
||||||
|
|
||||||
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
|
networking.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.enp0s3.useDHCP = lib.mkDefault true;
|
||||||
|
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
virtualisation.virtualbox.guest.enable = true;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue