Changer son environnement fullstack en un clin d’oeil avec devenv
A presentation at DevFest Nantes in October 2023 in Nantes, France by Julien Tanguy
Changer son environnement fullstack en un clin d’oeil avec devenv
Qui sommes-nous Julien Tanguy Developer @jutanguy hello@jtanguy.me
Qui sommes-nous Anthony Pena Developer @_Anthony_Pena anthony.pena@outlook.fr
Prérequis Un environnement de développement linux-like • Linux • MacOS • WSL2 pour Windows • Github codespaces: https://github.com/jtanguy/workshop-devenv
Lab Installation • https://github.com/jtanguy/workshop-devenv • Lancer un codespace Étape: Installation
Lab Installation (Alt) https://devenv.sh/getting-started/ • installer Nix • installer Cachix • installer Devenv Étape: Installation
Contexte
Problématique
Problématique • Comment gérer les outils de développement ?
Problématique • Comment gérer les outils de développement ? • Comment faciliter l’installation d’un nouveau poste ?
Problématique • Comment gérer les outils de développement ? • Comment faciliter l’installation d’un nouveau poste ? • Comment mettre à jour, maintenir et diffuser des évolutions de ces outils ?
Problématique • Comment gérer les outils de développement ? • Comment faciliter l’installation d’un nouveau poste ? • Comment mettre à jour, maintenir et diffuser des évolutions de ces outils ? • Comment faciliter le développement en local ?
Solutions
Solutions • Gestion des versions des langages: nvm, sdkman, rvm
Solutions • Gestion des versions des langages: nvm, sdkman, rvm • Outils multi-languages et multi-outils: asdf
Solutions • Gestion des versions des langages: nvm, sdkman, rvm • Outils multi-languages et multi-outils: asdf • Comment gérer les services annexes: db, reverse-proxy, process autres ?
Pourquoi devenv ?
Avantages
Avantages • Gestion de nombreux langages
Avantages • Gestion de nombreux langages • Gestion des services annexes
Avantages • Gestion de nombreux langages • Gestion des services annexes • Se repose sur un vrai package manager: nix
Avantages • Gestion de nombreux langages • Gestion des services annexes • Se repose sur un vrai package manager: nix • Se repose sur le plus grand repository: nixpkgs
Nixpkgs 57000 nixpkgs unstable Number of fresh packages in repository nixpkgs stable 23.05 nixpkgs stable 22.11 nixpkgs stable 22.05 nixpkgs stable 21.11 AUR CRAN FreeBSD Ports Debian Unstable Devuan Unstable Debian Kali Linux 13Raspbian Rolling Testing Ubuntu 23.10 Hackage PyPI Fedora Rawhide Fedora 39 Raspbian Stable Debian Ubuntu 12 23.04 PureOS landing Fedora 38 Fedora 37 LiGurOS develop Ubuntu11.0 22.04 Trisquel Gentoo Raspbian Oldstable MacPorts LiGurOS stable openSUSE Tumbleweed Fedora 36 Parrot Debian Devuan Pardus 21 11 4.0 CPAN pkgsrc ALT Sisyphus current MetaCPAN Unstable FedoraGNU 35 Guix Manjaro Arch ParabolaTesting Rosa 2021.1 Manjaro Stable Fedora 34 Ubuntu 20.04 Alpine Linux Edge Trisquel 10.0 Mageia cauldron Arch Linux ARM aarch64 Fedora 33 Debian 10 PureOS Devuan DeepinAmber 3.0 Fedora Fedora 32 31 Fedora 30 29 ALT Linux p10 28 Ubuntu 18.04 Fedora i686 Arch Linux OpenMandriva 32 pentium4 Fedora Rolling Cooker 27 OpenMandriva 4.3 Rosa Fedora 2016.1 26 OpenBSD PLDPorts Linux ALT OpenMandriva 4.2 Homebrew Void Linux x86_64 Rosa 2014.1 openSUSE Leap Linux 15.5 p9 Ubuntu 16.04 OpenMandriva 4.1 Arch Linux 32 i486 OpenMandriva 4.0 Mageia 8 SlackBuilds BioArch openmamba Ubuntu 14.04 RubyGems Artix openSUSE Leap 15.4 Alpine Linux 3.18 PCLinuxOS crates.io Exherbo EPEL 9 openSUSELeap Leap15.2 15.3 Stackage Nightly Ravenports openSUSE MELPA Stable Spack Stackage Wikidata LTS Haskell Alpine Linux openSUSE 3.17 Leap 15.0 T2 SDE openSUSE Leap 15.1 Solus Scoop YACP openSUSE EPEL Alpine EPEL 8 Linux 7 mports 3.16 Leap 42.3 ArchPOWER powerpc powerpc64le ArchPOWER riscv64 OpenIndiana Termux packages KaOS MSYS2 Pisi MidnightBSD Linux Alpine mingw Linux 3.15 CRUX Buildroot 3.7 master Apertis v2023 v2022 v2024 Development Slackware Slackware64 SliTaz Alpine Cooking current current Linux 3.14 Homebrew Casks Cygwin openEuler BlackArch Alpine 2023.05.x Linux 22.03 3.13 RPM Debian Buildroot Chocolatey Sphere Janitor 2023.02.x Releases EPEL 6 HaikuPorts Alpine Linux master 3.12 winget Adélie Linux current Gentoo overlay GURU ConanCenter Vcpkg SliTaz Alpine Next Linux 3.11 OpenPKG CentOS Alpine GoboLinux Apertis Stream Linux v2021 3.10 97.x CRUX EuroLinux Rocky AlmaLinux Alpine 3.6 Linux Linux 9Linux 9 915.0 3.8 3.9 openSUSE AlmaLinux EuroLinux Rocky CentOS Rosa Linux games Server Stream 88 8 Tumbleweed 7.5 8 Entware CentOS Scientific Rosa 3.5 Server science 8 7.3 Tumbleweed GNU MSYS2 Debian Slackwarearm Slackware Slackware64 Amazon Elpa msys2 Experimental 7 Linux 15.0 15.0 2 Deb HP-UX freshcode.club Gentoo openEuler Multimedia Rosa 11.31 overlay Server 22.03 20.03 Unstable Pentoo 6.9 LuaRocks Carbs Libregamewiki OS4Depot Npackd AIX CRUX Debian Slackware Slackware64 Slackwarearm Ataraxia Amazon CentOS Open Linux 3.4 Stable 11 GNU/Linux Source 6 Linux 14.2 Backports 14.2 14.2 1 Packages DistroWatch.com openSUSE Terra RPM PackMan PackMan MPR yiffOS OpenWrt OpenWrt Debian Fusion 38 39 37 Knot openSUSE openSUSE 10 network multimedia:apps multimedia:libs graphics 19.07 Fedora 21.02 Debian Backports x86_64 x86_64 Rawhide Tumbleweed 37 Tumbleweed Janitor Tumbleweed Leap 15.2 42.3 15.0 15.1 Tumbleweed -Backports Tumbleweed Snapshots glaucus WakeMeOps NOIR Ubuntu Homebrew Npackd Pisi openSUSE RebornOS SageMath MX pacstall Gentoo AIX MX MX UBI OpenWrt OpenWrt Linux Toolbox Linux 8 Linux 23.10 Stable64 Science SLE Contrib MX-21 MX-21 MX-19 stable development hardware:sdr security 17.01 MX-19 Education 18.06 tap Main 12 Proposed Brewsci/bio overlay Testing x86_64 x86_64 Testing Tumbleweed Tumbleweed Tumbleweed F-Droid KaOS MX openSUSE Pardus Trisquel Arch Baulk Calculate Tails RPM BackBox antiX-16 Endless Linux LMDE PackMan ReactOS Sabayon Sparky UnitedRPMs Kali antiX-17 IBM KaOS KISS postmarketOS just-install Software MX Siduction antiX-21 antiX-19 Salix distri KDE AppGet KDE postmarketOS Linux Linux Linux iFusion stable devel Testing neon Linux Build Mint neon 14.2 4 5 kde-next 23 Stable Testing 22.04 20.04 14.04 10.0 11.0 OS 6 7 rapps for-gentoo SLE MX-23 Collections MX-23 Bleeding server:irc shells 20 20.1 21 21.1 Emulators 20.2 20.3 User Testing Games 4.0 Unstable EL master Hydrogen Helium backports 15 9 6 8 7 20.05 22.12 21.03 master LTS Testing Tumbleweed Edge 35 36 32 33 34 Tumbleweed 0 Ubuntu Npackd Siduction BunsenLabs Parabola ELRepo 18.04 16.04 23.04 el7 Unstable Testing Experimental Testing MELPA Hydrogen/Jessie Helium/Stretch Backports Backports 0 Number of packages in repository 87000
Introduction à Nix
Nix “ Nix est un package manager déclaratif ”
Nix store 1 2 3 4 5 6 7 8 9 10 11 12 13 14 $ which lnav /nix/store/hcv2abrk1mhsnz67xjasg3pwz4wdkw7q-devenv-profile/bin/lnav $ ls /nix/store/hcv2abrk1mhsnz67xjasg3pwz4wdkw7q-devenv-profile/bin/ -la total 36 dr-xr-xr-x 2 root root 4096 Jan 1 1970 ./ dr-xr-xr-x 6 root root 4096 Jan 1 1970 ../ lrwxrwxrwx 3 root root 71 Jan 1 1970 corepack -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/corepack* lrwxrwxrwx 3 root root 67 Jan 1 1970 honcho -> /nix/store/am744diswph5ml71n562k2rwhwk3ipw0-honcho-1.1.0/bin/honcho* lrwxrwxrwx 3 root root 76 Jan 1 1970 .honcho-wrapped -> /nix/store/am744diswph5ml71n562k2rwhwk3ipw0-honcho-1.1.0/bin/.honcho-wrapped* lrwxrwxrwx 2 root root 64 Jan 1 1970 lnav -> /nix/store/c9psaxm0syj8rriqdy8zaxns9s997rhk-lnav-0.11.2/bin/lnav* lrwxrwxrwx 3 root root 67 Jan 1 1970 node -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/node* lrwxrwxrwx 3 root root 66 Jan 1 1970 npm -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/npm* lrwxrwxrwx 3 root root 66 Jan 1 1970 npx -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/npx*
Nix store 1 2 3 4 5 6 7 8 9 10 11 12 13 14 $ which lnav /nix/store/hcv2abrk1mhsnz67xjasg3pwz4wdkw7q-devenv-profile/bin/lnav $ ls /nix/store/hcv2abrk1mhsnz67xjasg3pwz4wdkw7q-devenv-profile/bin/ -la total 36 dr-xr-xr-x 2 root root 4096 Jan 1 1970 ./ dr-xr-xr-x 6 root root 4096 Jan 1 1970 ../ lrwxrwxrwx 3 root root 71 Jan 1 1970 corepack -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/corepack* lrwxrwxrwx 3 root root 67 Jan 1 1970 honcho -> /nix/store/am744diswph5ml71n562k2rwhwk3ipw0-honcho-1.1.0/bin/honcho* lrwxrwxrwx 3 root root 76 Jan 1 1970 .honcho-wrapped -> /nix/store/am744diswph5ml71n562k2rwhwk3ipw0-honcho-1.1.0/bin/.honcho-wrapped* lrwxrwxrwx 2 root root 64 Jan 1 1970 lnav -> /nix/store/c9psaxm0syj8rriqdy8zaxns9s997rhk-lnav-0.11.2/bin/lnav* lrwxrwxrwx 3 root root 67 Jan 1 1970 node -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/node* lrwxrwxrwx 3 root root 66 Jan 1 1970 npm -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/npm* lrwxrwxrwx 3 root root 66 Jan 1 1970 npx -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/npx*
Nix store 1 2 3 4 5 6 7 8 9 10 11 12 13 14 $ which lnav /nix/store/hcv2abrk1mhsnz67xjasg3pwz4wdkw7q-devenv-profile/bin/lnav $ ls /nix/store/hcv2abrk1mhsnz67xjasg3pwz4wdkw7q-devenv-profile/bin/ -la total 36 dr-xr-xr-x 2 root root 4096 Jan 1 1970 ./ dr-xr-xr-x 6 root root 4096 Jan 1 1970 ../ lrwxrwxrwx 3 root root 71 Jan 1 1970 corepack -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/corepack* lrwxrwxrwx 3 root root 67 Jan 1 1970 honcho -> /nix/store/am744diswph5ml71n562k2rwhwk3ipw0-honcho-1.1.0/bin/honcho* lrwxrwxrwx 3 root root 76 Jan 1 1970 .honcho-wrapped -> /nix/store/am744diswph5ml71n562k2rwhwk3ipw0-honcho-1.1.0/bin/.honcho-wrapped* lrwxrwxrwx 2 root root 64 Jan 1 1970 lnav -> /nix/store/c9psaxm0syj8rriqdy8zaxns9s997rhk-lnav-0.11.2/bin/lnav* lrwxrwxrwx 3 root root 67 Jan 1 1970 node -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/node* lrwxrwxrwx 3 root root 66 Jan 1 1970 npm -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/npm* lrwxrwxrwx 3 root root 66 Jan 1 1970 npx -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/npx*
Nix store 1 2 3 4 5 6 7 8 9 10 11 12 13 14 $ which lnav /nix/store/hcv2abrk1mhsnz67xjasg3pwz4wdkw7q-devenv-profile/bin/lnav $ ls /nix/store/hcv2abrk1mhsnz67xjasg3pwz4wdkw7q-devenv-profile/bin/ -la total 36 dr-xr-xr-x 2 root root 4096 Jan 1 1970 ./ dr-xr-xr-x 6 root root 4096 Jan 1 1970 ../ lrwxrwxrwx 3 root root 71 Jan 1 1970 corepack -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/corepack* lrwxrwxrwx 3 root root 67 Jan 1 1970 honcho -> /nix/store/am744diswph5ml71n562k2rwhwk3ipw0-honcho-1.1.0/bin/honcho* lrwxrwxrwx 3 root root 76 Jan 1 1970 .honcho-wrapped -> /nix/store/am744diswph5ml71n562k2rwhwk3ipw0-honcho-1.1.0/bin/.honcho-wrapped* lrwxrwxrwx 2 root root 64 Jan 1 1970 lnav -> /nix/store/c9psaxm0syj8rriqdy8zaxns9s997rhk-lnav-0.11.2/bin/lnav* lrwxrwxrwx 3 root root 67 Jan 1 1970 node -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/node* lrwxrwxrwx 3 root root 66 Jan 1 1970 npm -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/npm* lrwxrwxrwx 3 root root 66 Jan 1 1970 npx -> /nix/store/x8vrc1c6r8nn454whr99bxc5hdy5ybjf-nodejs-18.18.0/bin/npx*
Cachix “ Nix binary cache hosting ”
Devenv “ Fast, Declarative, Reproducible, and Composable Developer Environments using Nix ”
Hello nix
Lab Hello world • Initialiser devenv • Démarrer le devenv shell • Observer les changements sur git • devenv info Étape: 01-hello-world
Devenv: syntaxe, doc et languges
devenv.yaml inputs: nixpkgs: url: github:NixOS/nixpkgs/nixpkgs-unstable
devenv.yaml allowUnfree: true inputs: nixpkgs: url: github:NixOS/nixpkgs/nixpkgs-unstable myproject: url: github:owner/myproject flake: false myproject2: url: github:owner/myproject overlays: - default imports: - ./frontend - ./backend - ./mymodule.nix - myproject myproject/relative/path
Syntaxe nix pour Devenv Exemple de fichier devenv.nix { pkgs, … }: { languages.rust = { enable = true; channel = “nightly”; components = [ “rustc” “cargo” “clippy” “rustfmt” “rust-analyzer” ]; }; #pre-commit.hooks = { # rustfmt.enable = true;
clippy.enable = true; #}; packages = [ pkgs.git pkgs.curl pkgs.jq pkgs.usql ]; } Chaque instruction se termine par un ;
Syntaxe nix Fonctions { pkgs, lib, … }: { # … } Le : sépare les arguments de la fonction de son corps
Syntaxe nix Attribute Sets - ou comment regrouper les clés { languages.rust.enable = true; languages.rust.channel = “nightly”; } { languages.rust = { enable = true; channel = “nightly”; } }
Syntaxe nix Tableaux { packages = [ pkgs.git pkgs.curl pkgs.jq pkgs.usql ]; } Pas de , entre les éléments d’un tableau
Nix Package https://search.nixos.org/packages
Référence de toutes les clés du devenv.nix https://devenv.sh/reference/options/
Lab Hello JQ • On ajoute le package jq • Help: devenv search jq Étape: 02-jq
Interlude direnv
direnv, un outil pour gérer votre $ENV # .envrc export WORKSHOP=”devenv” export CURRENT_STEP=”jq” 1 $ cd 02-jq 2 direnv: loading /workspaces/workshop-devenv/steps/02-jq/.envrc 3 direnv: export +CURRENT_STEP +WORKSHOP 4 5 $ cd .. 6 direnv: unloading
direnv, un outil pour gérer votre $ENV # .envrc export WORKSHOP=”devenv” export CURRENT_STEP=”jq” 1 $ cd 02-jq 2 direnv: loading /workspaces/workshop-devenv/steps/02-jq/.envrc 3 direnv: export +CURRENT_STEP +WORKSHOP 4 5 $ cd .. 6 direnv: unloading
direnv, un outil pour gérer votre $ENV # .envrc export WORKSHOP=”devenv” export CURRENT_STEP=”jq” 1 $ cd 02-jq 2 direnv: loading /workspaces/workshop-devenv/steps/02-jq/.envrc 3 direnv: export +CURRENT_STEP +WORKSHOP 4 5 $ cd .. 6 direnv: unloading
direnv, un outil pour gérer votre $ENV # .envrc export WORKSHOP=”devenv” export CURRENT_STEP=”jq” 1 $ cd 02-jq 2 direnv: loading /workspaces/workshop-devenv/steps/02-jq/.envrc 3 direnv: export +CURRENT_STEP +WORKSHOP 4 5 $ cd .. 6 direnv: unloading
Intégrations direnv 1 2 3 4 5 6
source_url “https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc” “sha256-YBzqskFZxmNb3kYVoKD9 use devenv L’intégration devenv lance automatiquement un devenv shell dans un dossier avec devenv
Intégrations direnv 1 2 3 4 5 6
source_url “https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc” “sha256-YBzqskFZxmNb3kYVoKD9 use devenv L’intégration devenv lance automatiquement un devenv shell dans un dossier avec devenv
Devenv: les languages
Avec des packages { pkgs, … }: { packages = [ pkgs.rustc pkgs.cargo pkgs.clippy pkgs.rustfmt pkgs.rust-analyzer } ];
Syntaxe des languages { pkgs, … }: { languages.rust = { enable = true; channel = “stable”; }; } https://devenv.sh/languages/
Comment garder devenv à jour ?
devenv update 1 $ devenv update 2 warning: updating lock file ‘/home/jtanguy/Sfeir/workshop-devenv/docs/devenv.lock’: 3 • Updated input ‘devenv’: 4 ‘github:cachix/devenv/895e8403410c3ec14d1e8cae94e88b4e7e2e8c2f?dir=src%2fmodules’ (2023-12-10) 5 → ‘github:cachix/devenv/0e68853bb27981a4ffd7a7225b59ed84f7180fc7?dir=src%2fmodules’ (2024-02-03) 6 • Updated input ‘nixpkgs’: 7 ‘github:NixOS/nixpkgs/29d6c96900b9b576c2fb89491452f283aa979819’ (2023-12-10) 8 → ‘github:NixOS/nixpkgs/8cc79aa39bbc6eaedaf286ae655b224c71e02907’ (2024-02-06) 9 • Updated input ‘pre-commit-hooks’: 10 ‘github:cachix/pre-commit-hooks.nix/e1d203c2fa7e2593c777e490213958ef81f71977’ (2023-12-11) 11 → ‘github:cachix/pre-commit-hooks.nix/0db2e67ee49910adfa13010e7f012149660af7f0’ (2024-02-07) 12 • Updated input ‘pre-commit-hooks/flake-compat’: 13 ‘github:edolstra/flake-compat/35bb57c0c8d8b62bbfd284272c928ceb64ddbde9’ (2023-01-17) 14 → ‘github:edolstra/flake-compat/0f9255e01c2351cc7d116c072cb317785dd33b33’ (2023-10-04) 15 • Updated input ‘pre-commit-hooks/flake-utils’: 16 ‘github:numtide/flake-utils/a1720a10a6cfe8234c0e93907ffe81be440f4cef’ (2023-05-31) 17 → ‘github:numtide/flake-utils/4022d587cbbfd70fe950c1e2083a02621806a725’ (2023-12-04) 18 • Updated input ‘pre-commit-hooks/gitignore’: 19 ‘github:hercules-ci/gitignore.nix/a20de23b925fd8264fd7fad6454652e142fd7f73’ (2022-08-14) 20 → ‘github:hercules-ci/gitignore.nix/43e1aa1308018f37118e34d3a9cb4f5e75dc11d5’ (2023-12-29) 21 • Updated input ‘pre-commit-hooks/nixpkgs-stable’: 22 ‘github:NixOS/nixpkgs/c37ca420157f4abc31e26f436c1145f8951ff373’ (2023-06-03) 23 → ‘github:NixOS/nixpkgs/3dc440faeee9e889fe2d1b4d25ad0f430d449356’ (2024-01-10)
devenv update 1 $ devenv update 2 warning: updating lock file ‘/home/jtanguy/Sfeir/workshop-devenv/docs/devenv.lock’: 3 • Updated input ‘devenv’: 4 ‘github:cachix/devenv/895e8403410c3ec14d1e8cae94e88b4e7e2e8c2f?dir=src%2fmodules’ (2023-12-10) 5 → ‘github:cachix/devenv/0e68853bb27981a4ffd7a7225b59ed84f7180fc7?dir=src%2fmodules’ (2024-02-03) 6 • Updated input ‘nixpkgs’: 7 ‘github:NixOS/nixpkgs/29d6c96900b9b576c2fb89491452f283aa979819’ (2023-12-10) 8 → ‘github:NixOS/nixpkgs/8cc79aa39bbc6eaedaf286ae655b224c71e02907’ (2024-02-06) 9 • Updated input ‘pre-commit-hooks’: 10 ‘github:cachix/pre-commit-hooks.nix/e1d203c2fa7e2593c777e490213958ef81f71977’ (2023-12-11) 11 → ‘github:cachix/pre-commit-hooks.nix/0db2e67ee49910adfa13010e7f012149660af7f0’ (2024-02-07) 12 • Updated input ‘pre-commit-hooks/flake-compat’: 13 ‘github:edolstra/flake-compat/35bb57c0c8d8b62bbfd284272c928ceb64ddbde9’ (2023-01-17) 14 → ‘github:edolstra/flake-compat/0f9255e01c2351cc7d116c072cb317785dd33b33’ (2023-10-04) 15 • Updated input ‘pre-commit-hooks/flake-utils’: 16 ‘github:numtide/flake-utils/a1720a10a6cfe8234c0e93907ffe81be440f4cef’ (2023-05-31) 17 → ‘github:numtide/flake-utils/4022d587cbbfd70fe950c1e2083a02621806a725’ (2023-12-04) 18 • Updated input ‘pre-commit-hooks/gitignore’: 19 ‘github:hercules-ci/gitignore.nix/a20de23b925fd8264fd7fad6454652e142fd7f73’ (2022-08-14) 20 → ‘github:hercules-ci/gitignore.nix/43e1aa1308018f37118e34d3a9cb4f5e75dc11d5’ (2023-12-29) 21 • Updated input ‘pre-commit-hooks/nixpkgs-stable’: 22 ‘github:NixOS/nixpkgs/c37ca420157f4abc31e26f436c1145f8951ff373’ (2023-06-03) 23 → ‘github:NixOS/nixpkgs/3dc440faeee9e889fe2d1b4d25ad0f430d449356’ (2024-01-10)
devenv update 1 $ devenv update 2 warning: updating lock file ‘/home/jtanguy/Sfeir/workshop-devenv/docs/devenv.lock’: 3 • Updated input ‘devenv’: 4 ‘github:cachix/devenv/895e8403410c3ec14d1e8cae94e88b4e7e2e8c2f?dir=src%2fmodules’ (2023-12-10) 5 → ‘github:cachix/devenv/0e68853bb27981a4ffd7a7225b59ed84f7180fc7?dir=src%2fmodules’ (2024-02-03) 6 • Updated input ‘nixpkgs’: 7 ‘github:NixOS/nixpkgs/29d6c96900b9b576c2fb89491452f283aa979819’ (2023-12-10) 8 → ‘github:NixOS/nixpkgs/8cc79aa39bbc6eaedaf286ae655b224c71e02907’ (2024-02-06) 9 • Updated input ‘pre-commit-hooks’: 10 ‘github:cachix/pre-commit-hooks.nix/e1d203c2fa7e2593c777e490213958ef81f71977’ (2023-12-11) 11 → ‘github:cachix/pre-commit-hooks.nix/0db2e67ee49910adfa13010e7f012149660af7f0’ (2024-02-07) 12 • Updated input ‘pre-commit-hooks/flake-compat’: 13 ‘github:edolstra/flake-compat/35bb57c0c8d8b62bbfd284272c928ceb64ddbde9’ (2023-01-17) 14 → ‘github:edolstra/flake-compat/0f9255e01c2351cc7d116c072cb317785dd33b33’ (2023-10-04) 15 • Updated input ‘pre-commit-hooks/flake-utils’: 16 ‘github:numtide/flake-utils/a1720a10a6cfe8234c0e93907ffe81be440f4cef’ (2023-05-31) 17 → ‘github:numtide/flake-utils/4022d587cbbfd70fe950c1e2083a02621806a725’ (2023-12-04) 18 • Updated input ‘pre-commit-hooks/gitignore’: 19 ‘github:hercules-ci/gitignore.nix/a20de23b925fd8264fd7fad6454652e142fd7f73’ (2022-08-14) 20 → ‘github:hercules-ci/gitignore.nix/43e1aa1308018f37118e34d3a9cb4f5e75dc11d5’ (2023-12-29) 21 • Updated input ‘pre-commit-hooks/nixpkgs-stable’: 22 ‘github:NixOS/nixpkgs/c37ca420157f4abc31e26f436c1145f8951ff373’ (2023-06-03) 23 → ‘github:NixOS/nixpkgs/3dc440faeee9e889fe2d1b4d25ad0f430d449356’ (2024-01-10)
devenv update 1 $ devenv update 2 warning: updating lock file ‘/home/jtanguy/Sfeir/workshop-devenv/docs/devenv.lock’: 3 • Updated input ‘devenv’: 4 ‘github:cachix/devenv/895e8403410c3ec14d1e8cae94e88b4e7e2e8c2f?dir=src%2fmodules’ (2023-12-10) 5 → ‘github:cachix/devenv/0e68853bb27981a4ffd7a7225b59ed84f7180fc7?dir=src%2fmodules’ (2024-02-03) 6 • Updated input ‘nixpkgs’: 7 ‘github:NixOS/nixpkgs/29d6c96900b9b576c2fb89491452f283aa979819’ (2023-12-10) 8 → ‘github:NixOS/nixpkgs/8cc79aa39bbc6eaedaf286ae655b224c71e02907’ (2024-02-06) 9 • Updated input ‘pre-commit-hooks’: 10 ‘github:cachix/pre-commit-hooks.nix/e1d203c2fa7e2593c777e490213958ef81f71977’ (2023-12-11) 11 → ‘github:cachix/pre-commit-hooks.nix/0db2e67ee49910adfa13010e7f012149660af7f0’ (2024-02-07) 12 • Updated input ‘pre-commit-hooks/flake-compat’: 13 ‘github:edolstra/flake-compat/35bb57c0c8d8b62bbfd284272c928ceb64ddbde9’ (2023-01-17) 14 → ‘github:edolstra/flake-compat/0f9255e01c2351cc7d116c072cb317785dd33b33’ (2023-10-04) 15 • Updated input ‘pre-commit-hooks/flake-utils’: 16 ‘github:numtide/flake-utils/a1720a10a6cfe8234c0e93907ffe81be440f4cef’ (2023-05-31) 17 → ‘github:numtide/flake-utils/4022d587cbbfd70fe950c1e2083a02621806a725’ (2023-12-04) 18 • Updated input ‘pre-commit-hooks/gitignore’: 19 ‘github:hercules-ci/gitignore.nix/a20de23b925fd8264fd7fad6454652e142fd7f73’ (2022-08-14) 20 → ‘github:hercules-ci/gitignore.nix/43e1aa1308018f37118e34d3a9cb4f5e75dc11d5’ (2023-12-29) 21 • Updated input ‘pre-commit-hooks/nixpkgs-stable’: 22 ‘github:NixOS/nixpkgs/c37ca420157f4abc31e26f436c1145f8951ff373’ (2023-06-03) 23 → ‘github:NixOS/nixpkgs/3dc440faeee9e889fe2d1b4d25ad0f430d449356’ (2024-01-10)
devenv update 1 $ devenv update 2 warning: updating lock file ‘/home/jtanguy/Sfeir/workshop-devenv/docs/devenv.lock’: 3 • Updated input ‘devenv’: 4 ‘github:cachix/devenv/895e8403410c3ec14d1e8cae94e88b4e7e2e8c2f?dir=src%2fmodules’ (2023-12-10) 5 → ‘github:cachix/devenv/0e68853bb27981a4ffd7a7225b59ed84f7180fc7?dir=src%2fmodules’ (2024-02-03) 6 • Updated input ‘nixpkgs’: 7 ‘github:NixOS/nixpkgs/29d6c96900b9b576c2fb89491452f283aa979819’ (2023-12-10) 8 → ‘github:NixOS/nixpkgs/8cc79aa39bbc6eaedaf286ae655b224c71e02907’ (2024-02-06) 9 • Updated input ‘pre-commit-hooks’: 10 ‘github:cachix/pre-commit-hooks.nix/e1d203c2fa7e2593c777e490213958ef81f71977’ (2023-12-11) 11 → ‘github:cachix/pre-commit-hooks.nix/0db2e67ee49910adfa13010e7f012149660af7f0’ (2024-02-07) 12 • Updated input ‘pre-commit-hooks/flake-compat’: 13 ‘github:edolstra/flake-compat/35bb57c0c8d8b62bbfd284272c928ceb64ddbde9’ (2023-01-17) 14 → ‘github:edolstra/flake-compat/0f9255e01c2351cc7d116c072cb317785dd33b33’ (2023-10-04) 15 • Updated input ‘pre-commit-hooks/flake-utils’: 16 ‘github:numtide/flake-utils/a1720a10a6cfe8234c0e93907ffe81be440f4cef’ (2023-05-31) 17 → ‘github:numtide/flake-utils/4022d587cbbfd70fe950c1e2083a02621806a725’ (2023-12-04) 18 • Updated input ‘pre-commit-hooks/gitignore’: 19 ‘github:hercules-ci/gitignore.nix/a20de23b925fd8264fd7fad6454652e142fd7f73’ (2022-08-14) 20 → ‘github:hercules-ci/gitignore.nix/43e1aa1308018f37118e34d3a9cb4f5e75dc11d5’ (2023-12-29) 21 • Updated input ‘pre-commit-hooks/nixpkgs-stable’: 22 ‘github:NixOS/nixpkgs/c37ca420157f4abc31e26f436c1145f8951ff373’ (2023-06-03) 23 → ‘github:NixOS/nixpkgs/3dc440faeee9e889fe2d1b4d25ad0f430d449356’ (2024-01-10)
Hello python
Lab Hello python • Ajouter le package python • Lancer le script hello.py Étape: 03-python
Lab Hello python v2 • Migrer vers le language python • Lancer le script hello.py • Mettre à jour l’environnement de dev Étape: 03-python
Devenv: Scripts, processes et services
Scripts Permet de définir des scripts utilitaires au projet { pkgs, … }: { packages = [ pkgs.curl pkgs.jq ]; scripts.silly-example.exec = ” curl “https://httpbin.org/get?$1” | jq ‘.args’ ”; }
Scripts On peut utiliser les binaires sans les inclure dans le packages { pkgs, … }: { packages = [pkgs.jq]; scripts.devenv-bump-version.exec = ” # TODO: ask for the new version # TODO: update the version in the mkdocs.yml echo assuming you bumped the version in mkdocs.yml, populating src/modules/latest-version cat mkdocs.yml | ${pkgs.yaml2json}/bin/yaml2json | jq -r ‘.extra.devenv.version’ > src/modules/latest-version ”; }
Processes Les processes sont tous démarrés par devenv up (honcho est utilisé sous le capot) { pkgs, … }: { processes = { silly-example.exec = “while true; do echo hello && sleep 1; done”; ping.exec = “ping example.com”; }; } $ devenv up Starting processes … 20:37:44 20:37:44 20:37:44 20:37:44 20:37:44 20:37:45 20:37:45 20:37:46 20:37:46 20:37:47 20:37:47 … system system silly-example.1 ping.1 ping.1 silly-example.1 ping.1 silly-example.1 ping.1 silly-example.1 ping.1 | | | | | | | | | | | ping.1 started (pid=4094686) silly-example.1 started (pid=4094688) hello PING example.com (93.184.216.34) 56(84) bytes of data. 64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=1 hello 64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=2 hello 64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=3 hello 64 bytes from 93.184.216.34 (93.184.216.34): icmp_seq=4 ttl=55 time=125 ms ttl=55 time=125 ms ttl=55 time=125 ms ttl=55 time=125 ms
Services • packages -> languages • processes -> services https://devenv.sh/services/#supported-services { pkgs, … }: { services.redis.enable = true; }
Hello Scripts, Processes et Services
Lab Script, process et service • Écrire un process docs qui lance mkdocs serve • Configurer le service postgres pour créer une DB workshop avec ./db/init.sql • Créer un script pour se connecter à la DB avec usql postgres://localhost:5432/workshop Étape: 04-scripts
Hello Realworld
Lab Realworld app • Backend + frontend • PostgreSQL en DB Étape: 05-realworld