Giter Club home page Giter Club logo

nixos-configuration.nix's Introduction

Hi there ๐Ÿ‘‹, I am Pedro Regis

Pedro Regis's github stats:

Languages

Nix Python Shell Script

Cloud & DevOps

Docker Podman Vagrant Terraform Datadog GitHub Actions QEMU Amazon EC2 Amazon S3 proxmox

Unix

Linux NixOS Debian Ubuntu Alpine Linux XFCE Git

Databases

PostgreSQL Redis SQLite

Backend

Django DjangoREST Celery RabbitMQ

Other

Postman Insomnia DBeaver GitKraken PyCharm Jupyter Notebook Neovim YAML json toml Markdown

Contact

LinkedIn

nixos-configuration.nix's People

Contributors

pedroregispoar avatar

Watchers

 avatar  avatar  avatar

nixos-configuration.nix's Issues

Things to be documented

Installation

Really useful:
https://releases.nixos.org/?prefix=nixos/22.05/

TODO: Part 0, could merge the injection of the flag --extra-experimental-features 'nix-command flakes'

Part 1: should work in almost every place, only needed nix CLI working (tested it in Ubuntu 20.04)

nix --extra-experimental-features 'nix-command flakes' shell nixpkgs#wget nixpkgs#coreutils

Part 2: downloading some fixed/pinned url's NixOS ISO and testing its sha256sum

wget https://releases.nixos.org/nixos/22.05/nixos-22.05.1460.9e96b1562d6/nixos-plasma5-22.05.1460.9e96b1562d6-x86_64-linux.iso

wget https://releases.nixos.org/nixos/22.05/nixos-22.05.1460.9e96b1562d6/nixos-plasma5-22.05.1460.9e96b1562d6-x86_64-linux.iso.sha256
cat nixos-plasma5-22.05.1460.9e96b1562d6-x86_64-linux.iso.sha256 | sha256sum -c

Part 3: making an bootable flash drive/USB stick

# nix --extra-experimental-features 'nix-command flakes' run nixpkgs#etcher
NIXPKGS_ALLOW_INSECURE=1 nix --extra-experimental-features 'nix-command flakes' run nixpkgs#etcher --impure

From:

Part 4: install it using the Calamares graphical installer

Part 5: after the install just copy paste

nix \
--extra-experimental-features 'nix-command flakes' \
profile \
install \
nixpkgs#gitMinimal


test -f "$HOME"/.gitconfig || { cat << EOF > "$HOME"/.gitconfig
[user]
    name = Pedro O. A. Regis
    email = [email protected]
EOF
} && git config --list \
&& git config user.name \
&& git config user.email


sudo cp -r /etc/nixos/ /etc/nixos-backup \
&& sudo rm -f /etc/nixos/{configuration.nix,hardware-configuration.nix} \
&& sudo chown "$(id -u)":"$(id -g)" -R /etc/nixos \
&& nix \
flake \
--extra-experimental-features 'nix-command flakes' \
clone \
github:PedroRegisPOAR/NixOS-configuration.nix \
--dest /etc/nixos/


# TODO: explain this magic
cd /etc/nixos/ \
&& git remote set-url origin $(git remote show origin | grep "Fetch URL" | sed 's/ *Fetch URL: //' | sed 's/https:\/\/github.com\//[email protected]:/')

# nix \
# build \
# github:PedroRegisPOAR/NixOS-configuration.nix#nixosConfigurations.pedroregispoar.config.system.build.toplevel
# 
# TODO: study
# sudo nixos-rebuild boot --install-bootloader --flake '/etc/nixos#pedroregispoar'

cd /etc/nixos/ \
&& git checkout nixos-22.05 \
&& cp -f /etc/nixos-backup/hardware-configuration.nix /etc/nixos/  \
&& git add hardware-configuration.nix \
&& git commit -m 'Adds newly created hardware-configuration.nix'

sudo \
-E \
su \
-p \
-c \
"
nixos-rebuild test --flake '/etc/nixos#pedroregispoar' \
&& nixos-rebuild switch --flake '/etc/nixos#pedroregispoar' \
&& reboot
"

Once I got this erros, and I was willing to save time, so pressed Ctrl + c:

[sudo] password for pedro: 
Cloning into '/etc/nixos'...
remote: Enumerating objects: 659, done.
remote: Counting objects: 100% (145/145), done.
remote: Compressing objects: 100% (99/99), done.
remote: Total 659 (delta 93), reused 98 (delta 46), pack-reused 514
Receiving objects: 100% (659/659), 102.59 KiB | 1.07 MiB/s, done.
Resolving deltas: 100% (405/405), done.
branch 'nixos-22.05' set up to track 'origin/nixos-22.05'.
Switched to a new branch 'nixos-22.05'
[nixos-22.05 d0584dd] Adds newly created hardware-configuration.nix
 1 file changed, 2 insertions(+), 2 deletions(-)
building the system configuration...
warning: error: unable to download 'https://cache.nixos.org/nar/0b2vvkawcb1xx2kczi8yjj9bkm4rsgbqzw6673jn2a2xlyarai46.nar.xz': HTTP error 200 ('') (curl error: Timeout was reached); retrying from offset 35651584 in 346 ms
warning: error: unable to download 'https://cache.nixos.org/nar/10j3b9c6r4qxhrzwynm7x6xj9f6phm5w4gqdxb23y8q4140dccbf.nar.xz': HTTP error 200 ('') (curl error: Timeout was reached); retrying from offset 5214729 in 251 ms
warning: error: unable to download 'https://cache.nixos.org/nar/0szhzmbj0bhpnbm7nsgrxsbk7hyp7zpm75jvzys7ihkacahhsckw.nar.xz': HTTP error 200 ('') (curl error: Timeout was reached); retrying from offset 4620279 in 290 ms
warning: error: unable to download 'https://cache.nixos.org/nar/1rx22qyn2hq5lq3xy2zkvydqdh6wmcavqa6yj30hqc7ks1b0snck.nar.xz': HTTP error 200 ('') (curl error: Timeout was reached); retrying from offset 1245184 in 325 ms
warning: error: unable to download 'https://cache.nixos.org/nar/10j3b9c6r4qxhrzwynm7x6xj9f6phm5w4gqdxb23y8q4140dccbf.nar.xz': Timeout was reached (28); retrying from offset 5214729 in 695 ms
warning: error: unable to download 'https://cache.nixos.org/nar/0szhzmbj0bhpnbm7nsgrxsbk7hyp7zpm75jvzys7ihkacahhsckw.nar.xz': Timeout was reached (28); retrying from offset 4620279 in 527 ms
warning: error: unable to download 'https://cache.nixos.org/nar/1rx22qyn2hq5lq3xy2zkvydqdh6wmcavqa6yj30hqc7ks1b0snck.nar.xz': Timeout was reached (28); retrying from offset 1245184 in 595 ms
warning: error: unable to download 'https://cache.nixos.org/nar/0b2vvkawcb1xx2kczi8yjj9bkm4rsgbqzw6673jn2a2xlyarai46.nar.xz': Timeout was reached (28); retrying from offset 35651584 in 677 ms
warning: error: unable to download 'https://cache.nixos.org/nar/0szhzmbj0bhpnbm7nsgrxsbk7hyp7zpm75jvzys7ihkacahhsckw.nar.xz': Timeout was reached (28); retrying from offset 4620279 in 1057 ms
warning: error: unable to download 'https://cache.nixos.org/nar/10j3b9c6r4qxhrzwynm7x6xj9f6phm5w4gqdxb23y8q4140dccbf.nar.xz': Timeout was reached (28); retrying from offset 5214729 in 1362 ms
warning: error: unable to download 'https://cache.nixos.org/nar/1rx22qyn2hq5lq3xy2zkvydqdh6wmcavqa6yj30hqc7ks1b0snck.nar.xz': Timeout was reached (28); retrying from offset 1245184 in 1178 ms
warning: error: unable to download 'https://cache.nixos.org/nar/0b2vvkawcb1xx2kczi8yjj9bkm4rsgbqzw6673jn2a2xlyarai46.nar.xz': Timeout was reached (28); retrying from offset 35651584 in 1328 ms
[0/770 built, 4/97/1558 copied (255.6/11625.5 MiB), 44.6/3713.1 MiB DL] fetching font-adobe-75dpi-1.0.3 from https://cache.nixos.org^C
error: interrupted by the user

And re run the last command.

Part 6: after the reboot, lets generate an new key to be able to use git via ssh

Note: considering having an flash drive bootable, backup and install from scratch
(github/some remote) is really magic.

For some really unknown reason the system just did not show up the interface any more, broken system.

I did not want to spend lots of time trying to figure out an hack way to recover the system. I did a boot
from this previously built flash drive and backup the "frozen" (actually read only file system)
from the just died system and a full re install.

command -v ssh-keygen || nix profile install nixpkgs#openssh
command -v git || nix profile install nixpkgs#git

ssh-keygen \
-t ed25519 \
-C "$(git config user.email)" \
-f "${HOME}"/.ssh/id_ed25519 \
-N '' \
&& echo \
&& cat "${HOME}"/.ssh/id_ed25519.pub \
&& echo

Go to:
https://github.com/settings/ssh/new

Optional, but recommended:

ssh -T -o ConnectTimeout=3 [email protected] &>/dev/null  
ssh -T -o ConnectTimeout=3 [email protected] &>/dev/null  
test $? -eq 1 || echo 'Error in ssh -T -o ConnectTimeout=3 [email protected]'

Part 7: removes the backup folder and push to the remote the new hardware-configuration.nix

sudo rm -fr /etc/nixos-backup

cd /etc/nixos/ \
&& git push

Troubleshooting

Am I booted in Legacy or UEFI?

[ -d /sys/firmware/efi/efivars ] && echo "UEFI" || echo "Legacy"

From: https://nixos.wiki/wiki/Bootloader

Not needed

nix \
--extra-experimental-features 'nix-command flakes' \
flake \
update \
--override-input nixpkgs github:NixOS/nixpkgs/nixos-22.05
nix \
--extra-experimental-features 'nix-command flakes' \
flake \
update \
--override-input nixpkgs github:SuperSandro2000/nixpkgs/i18n-always-c

https://www.youtube.com/watch?v=aeDbYuJyXr8&t=43s

nix \
--extra-experimental-features 'nix-command flakes' \
build \
github:PedroRegisPOAR/NixOS-configuration.nix/nixos-22.05#nixosConfigurations.pedroregispoar.config.system.build.toplevel

I was being hitted by a really annoying permission denied error.

Solution:

sudo chown --recursive pedro  /etc/nixos

Generalise?

sudo chown --recursive "$USER" /etc/nixos
nix \
build \
github:PedroRegisPOAR/NixOS-configuration.nix#nixosConfigurations.pedroregispoar.config.system.build.toplevel

https://github.com/tfc/nixos-offline-installer#how-to-test-in-qemu

https://search.nixos.org/options?channel=22.05&show=system.copySystemConfiguration&from=0&size=50&sort=relevance&type=packages&query=copySystemConfiguration

https://discourse.nixos.org/t/declarative-kde-configuration/15901/5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.