Reset from scratch

This commit is contained in:
Florian RICHER 2023-08-19 15:05:58 +02:00
parent 143bd363a1
commit ae5e6508bc
10 changed files with 0 additions and 652 deletions

1
.gitignore vendored
View file

@ -1 +0,0 @@
/result

View file

@ -1,143 +0,0 @@
# 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, ... }:
let
user="florian";
in
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.efi.efiSysMountPoint = "/boot/efi";
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/Paris";
# Select internationalisation properties.
i18n.defaultLocale = "fr_FR.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "fr_FR.UTF-8";
LC_IDENTIFICATION = "fr_FR.UTF-8";
LC_MEASUREMENT = "fr_FR.UTF-8";
LC_MONETARY = "fr_FR.UTF-8";
LC_NAME = "fr_FR.UTF-8";
LC_NUMERIC = "fr_FR.UTF-8";
LC_PAPER = "fr_FR.UTF-8";
LC_TELEPHONE = "fr_FR.UTF-8";
LC_TIME = "fr_FR.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 = "fr";
xkbVariant = "us";
};
# Configure console keymap
console.keyMap = "fr";
# Enable CUPS to print documents.
services.printing.enable = true;
# Enable sound with pipewire.
sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
# If you want to use JACK applications, uncomment this
#jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};
# 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.${user} = {
isNormalUser = true;
description = "Florian RICHER";
extraGroups = [ "networkmanager" "wheel" ];
packages = with pkgs; [
firefox
# thunderbird
];
};
# 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
vscode
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. Its 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?
# BEGIN: Add flake feature TODO: Remove when not experimental
nix = {
package = pkgs.nixFlakes;
extraOptions = "experimental-features = nix-command flakes";
};
# END: Add flake feature
}

View file

@ -1,84 +0,0 @@
# Important
Cette documentation est un résumé de ce que j'ai compris sur le fonctionnement derrière NixOS.
Je suis encore en train de découvrir son fonctionnement donc si la documentation contient des erreurs merci de me les communiquer.
# Lexique
- **nix-store** (/nix/store) -> Remplace l'actuelle /lib /usr/lib /bin ...
> Il permet de stocker les dépendances avec la version et hash précis.
>
> Ex: /nix/store/zyqz4419cwq4rdl3kmsjhhia2p2yzcmm-vscode-1.74.3.drv
>
> Contient l'ensemble des infos du packet vscode version 1.74.3
- **nix-channel**
> Un peu comme les repos sous Arch comme le repo multilib, docker, ...
- [**Home-Manager**](./home_manager/HOME.md)
> Permet d'installer des paquets uniquement pour un utilisateur spécifique
>
> Permet de gérer les dotfiles
# Commande utiles
```bash
nixos-version
```
```bash
nix-channel [--list/remove/add] url name
```
## nixos-rebuild
Reconstruire depuis /etc/nixos/configuration.nix
```bash
nixos-rebuild switch
```
Reconstruire depuis custom/configuration.nix
```bash
nixos-rebuild switch -I custom/configuration.nix
```
Reconstruire depuis la configuration [flake](./flake/HOME.md)
```bash
nixos-rebuild switch --flake flake_path_directory#hostname
```
## nix-collect-garbage
Retire les packets, dépendances et liens symboliques non déclarés (utilisé)
```bash
nix-collect-garbage --delete-old
```
Pareil mais pour les anciennes générations
```bash
nix-collect-garbage --delete-old
```
```bash
nix-env --list-generations
nix-env --delete-generations 14d
nix-env --delete-generations 10 11 # Jour spécifique
```
Pour le store
```bash
nix-store --gc
```
Pour tout faire d'un coup.
```bash
nix-collect-garbage -d
```
# Resource utile
- https://nixos.wiki/wiki/Overlays | Modifie ou ajoute des packets
- https://github.com/MatthiasBenaets/nixos-config

View file

@ -1,133 +0,0 @@
# Fonctionnement de flake
### Général
- Permet de télécharger des dépendances de code comme \<home-manager>
> Stocke les dépendances dans le fichier `flake.lock`.
> Si l'on souhaite figer la version des dépendances pour éviter tout risque de mauvaise configuration. On peut utiliser le fichier `flake.log`
- Permet de configurer facilement notre propre configuration comme depuis les dotfiles
### Installation
Pour le moment, flake est encore expérimental donc il faut l'activer manuellement.
/etc/nixos/configuration.nix
```nix
[...]
# BEGIN: Add flake feature TODO: Remove when not experimental
nix = {
package = pkgs.nixFlakes;
extraOptions = "experimental-features = nix-command flakes";
};
# END: Add flake feature
}
```
### Configuration initial
Génére le fichier `flake.nix`
```bash
nix flake init
```
`flake.nix`
```nix
{
description = "A very basic flake";
outputs = { self, nixpkgs }: {
packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
packages.x86_64-linux.default = self.packages.x86_64-linux.hello;
};
}
```
### Structure
#### Inputs
Défini l'ensemble des dépendances utilisées dans le `flake`
```nix
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
```
#### Outputs
Récupère les inputs dans la fonction en paramètre
- Permet de configurer ce que l'on a importé.
- Peut configurer les packages, configurations, modules, ...
```nix
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
lib = nixpkgs.lib;
in {
nixosConfigurations = {
# <hostname or user> specified with
# `nixos-rebuild [build/switch] --flake .#<hostname or user>`
<hostname or user> = lib.nixosSystem {
inherit system;
modules = [ ./configuration.nix ];
};
};
};
```
### Installation
`<hostname or user>` is default to `hostname or user` command but it can be overwritten
Build only
```bash
nixos-rebuild build --flake .#<hostname or user>
```
Build and switch
```bash
nixos-rebuild switch --flake .#<hostname or user>
```
Build script to activate in current shell
```bash
nix build .#hmConfig.<hostname or user>.activationPackage
```
with
```bash
./result/activate
```
### Updating
```bash
nix flake update #--recreate-lock-file
```
### Flake sur une installation vierge
Démarrage depuis l'ISO
```bash
sudo su
nix-env -iA nixos.git
git clone <repo url> /mnt/<path>
nixos-install --flake .#<host>
reboot
/* login */
# Car parfois, nixos peut compiler la version par défaut
sudo rm -r /etc/nixos/configuration.nix
/* move build to desired location */
```

View file

@ -1,93 +0,0 @@
# Home manager
## Installation
**!!! Inutile si on utilise Flakes et que l'on install home-manager avec**
*sudo si l'on souhaite utiliser le module NixOS depuis /etc/nixos/configuration.nix*
```bash
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
```
or
```bash
nix-channel --add https://github.com/nix-community/home-manager/archive/release-${NIX_VERSION}.tar.gz home-manager
```
```bash
nix-channel --update
```
Relancer la session pour reload les channels pour le user courant.
**La version root non requis si on utilise flakes et nix-shell**
```bash
nix-shell '<home-manager>' -A install
```
## Configuration
$HOME/.config/nixpkgs/home.nix
```nix
{
...
home.packages = with pkgs; [ htop ];
services.dunst = {
enable = true;
};
home.file = {
".config/alacritty/alacritty.yml".text = ''
{"font":{"bold":{"style":"Bold"}}}
'';
};
home.file.".doom.d" = {
source = ./doom.d;
recursive = true;
onChange = builtins.readFile ./doom.sh;
};
home.file.".config/polybar/script/mic.sh" = {
source = ./mic.sh;
executable = true;
};
}
```
Cette exemple va générer le fichier *.config/bspwm/bspwmrc*
```nix
{
xsession = {
windowManager = {
bspwm = {
enable = true;
rules = {
"Emacs" = {
desktop = "3";
follow = true;
state = "tiled";
};
".blueman-manager-wrapped" = {
state = "floating";
sticky = true;
};
};
};
};
};
}
```
Mettre à jour les modifications
```bash
home-manager switch
```
```bash
man home-configuration.nix
```

View file

@ -1,24 +0,0 @@
# NIX syntaxe
### Declarer des variables dans un "scope"
```nix
let
[name]=[value];
in
{
...
}
```
### Keyword `with`
Sans
```nix
mavar = [ pkgs.htop ];
```
Avec
```nix
mavar = with pkgs; [ htop ];
```

View file

@ -1,62 +0,0 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"utils": "utils"
},
"locked": {
"lastModified": 1675247113,
"narHash": "sha256-+YcXjfCP4hNu8A68b/UoXFCTDwKLuLV+x/7dQnM5U/o=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "782cb855b2f23c485011a196c593e2d7e4fce746",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1675158573,
"narHash": "sha256-HkKEZA/8mt7iJ2eotjPMz6XUdjBW8E2aH0AoqLJ9vEs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e3945057be467f32028ff6b67403be08285ad8c8",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
},
"utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -1,52 +0,0 @@
{
description = "A very basic flake";
inputs = {
# nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = github:nix-community/home-manager;
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
lib = nixpkgs.lib;
in {
nixosConfigurations = {
florian = lib.nixosSystem {
inherit system;
modules = [
./configuration.nix
home-manager.nixosModules.home-manager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.florian = {
imports = [ ./home.nix ];
};
}
];
};
};
hmConfig = {
florian = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system};
modules = [
./home.nix
{
home = {
username = "florian";
homeDirectory = "/home/florian";
stateVersion = "22.11";
};
}
];
};
};
};
}

View file

@ -1,37 +0,0 @@
# 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 =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/6ac66f72-76b2-45d1-9405-7d44dc2b0556";
fsType = "ext4";
};
fileSystems."/boot/efi" =
{ device = "/dev/disk/by-uuid/D1D1-16BE";
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.enp1s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -1,23 +0,0 @@
{ config, pkgs, ... }:
{
# Home Manager needs a bit of information about you and the
# paths it should manage.
home.username = "florian";
home.homeDirectory = "/home/florian";
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "22.11";
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
home.packages = with pkgs; [ htop ];
}