From ec94f39e93f3260170f38b82af3636bbe9b117ce Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Sun, 14 Jun 2020 16:16:23 +0200 Subject: [PATCH 1/6] upgrade --- engine/draft-build.sh | 9 ++ src/css/y.css | 21 ++- src/drafts/XXXX-how-i-use-nix/index.org | 178 ++++++++++++++++++++++++ 3 files changed, 197 insertions(+), 11 deletions(-) create mode 100755 engine/draft-build.sh create mode 100644 src/drafts/XXXX-how-i-use-nix/index.org diff --git a/engine/draft-build.sh b/engine/draft-build.sh new file mode 100755 index 0000000..e4e79e5 --- /dev/null +++ b/engine/draft-build.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +cd "$(git rev-parse --show-toplevel)" || exit 1 +echo "* org-publish" +emacs -nw \ + --load project.el \ + --eval "(progn (org-publish \"draft\") (evil-quit))" + +echo "* org-publish [done]" diff --git a/src/css/y.css b/src/css/y.css index 45ddbe5..7fb425a 100644 --- a/src/css/y.css +++ b/src/css/y.css @@ -112,10 +112,10 @@ html { } body { - font-family: Georgia, Cambria, 'Times New Roman', Times, serif; - line-height: 1.8; + font-family: "American Typewriter", Georgia, Cambria, 'Times New Roman', Times, serif; + line-height: 1.5; - max-width: 80ch; + max-width: 60ch; min-height: 100vh; overflow-x: hidden; margin: 0 auto; @@ -178,9 +178,7 @@ article > * + * { code, pre, kbd { - font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', - monospace; - font-size: 85%; + font-family: Courier, monospace; } pre { padding: 1rem 1.4rem; @@ -189,6 +187,7 @@ pre { border: 1px solid hsl(210, 15%, 49%); border-radius: 4px; background: hsl(210, 40%, 96%); + font-size: 85%; } pre code { font-size: 95%; @@ -419,7 +418,7 @@ label:hover { cursor: pointer; } body { margin:0; padding: 0; border: 0; max-width: none;} #preamble, #postamble { text-align: center; } #content,.content,#preamble,#postamble { - max-width: 80ch; + max-width: 60ch; overflow: hidden; margin: 0 auto; } @@ -466,12 +465,12 @@ pre { line-height: 1em; } @media (prefers-color-scheme: dark) { :root { - --bg: black; + --bg: hsl(210,20%,11%); --rbg: var(--b03); --fg: var(--b1); --fg0: var(--b00); --rfg: var(--b2); - --hl: var(--y); + --hl: var(--g); } img { filter: brightness(0.7) saturate(0.5); } pre { @@ -499,12 +498,12 @@ input#l:checked ~ div pre { /* dark checked */ input#d:checked ~ div { - --bg: hsl(210,20%,2%); + --bg: hsl(210,20%,11%); --rbg: var(--b03); --fg: var(--b1); --fg0: var(--b00); --rfg: var(--b2); - --hl: var(--y); + --hl: var(--g); } input#d:checked ~ div img { filter: brightness(0.7) saturate(0.5); diff --git a/src/drafts/XXXX-how-i-use-nix/index.org b/src/drafts/XXXX-how-i-use-nix/index.org new file mode 100644 index 0000000..1715512 --- /dev/null +++ b/src/drafts/XXXX-how-i-use-nix/index.org @@ -0,0 +1,178 @@ +#+Title: How I use nix +#+Author: Yann Esposito +#+Email: yann@esposito.host +#+Date: [2020-06-14 Sun] +#+KEYWORDS: nix, programming +#+DESCRIPTION: In this article I explain how I use nix. +#+DESCRIPTION: As a brew replacement, as home environment manager, +#+DESCRIPTION: to have reproductible dev environment. +#+LANGUAGE: en +#+LANG: en +#+OPTIONS: H:5 auto-id:t toc:nil +#+STARTUP: showeverything + +In this article I'll explain how I use nix. +I don't use NixOS nor any Linux as my main desktop environment[fn:desktop]. +Still I use [[https://nixos.org/nix][nix]] on a few mac computers. +It has multiple usages. + +First, let's start by the bad news. +Recent macOS security policy made nix a bit harder to install on a mac. +See [[https://hydra.nixos.org/build/119559243/download/1/manual/#sect-macos-installation][macOS Installation instructions]]. + +Once you have nix installed you should update the nix-channel. +Mainly a nix-channels is where are the definitions of all the packages. +See [[https://hydra.nixos.org/build/119559243/download/1/manual/#sec-channels][nixOS documentation]]. + +** Home Manager +:PROPERTIES: +:CUSTOM_ID: home-manager +:END: + +First, I use [[https://github.com/rycee/home-manager][home-manager]], it's first usage it to list a reproductible list +of application I need on all my desktop environments. +So i edit the file =~/.config/nixpkgs/home.nix=. +I provide a list of packages I want to have when I start a new shell. + + +#+begin_src nix + home.packages = with pkgs; [ + # nix + nix-prefetch-git + lorri + # emacs + emacsMacport + imagemagick + gnupg + # vim + neovim + # shell + direnv + fasd + fd + findutils + fortune + gawk + git + gitAndTools.diff-so-fancy + graphviz + htop + httpie + jq + jwt-cli + libressl + mustache-go + pandoc + ripgrep + rtv + wakatime + xpdf # pdftotext + yadm + youtube-dl + # clojure + leiningen + boot + adoptopenjdk-bin + joker + # Haskell + ghc + cabal-install + (all-hies.selection + { selector = p: + { inherit (p) ghc865; };}) + # Common LISP + sbcl + # mails + offlineimap + notmuch + msmtp + gmailieer + # docker + docker-compose + # weechat + rel20weechat + aspell + aspellDicts.en + aspellDicts.fr + ]; +#+end_src + +There are a few noticiable artifact here: + +The first one is ~rel20weechat~ is a very specify build of weechat with the +plugin I need. So here is the block I use: + +#+begin_src nix +rel20 = import (fetchGit { + name = "nixpkgs20"; + url = "https://github.com/NixOS/nixpkgs"; + # obtained via + # git ls-remote https://github.com/NixOS/nixpkgs nixpkgs-20.03-darwin + ref = "refs/heads/nixpkgs-20.03-darwin"; + rev = "58f884cd3d89f47672e649c6edfb2382d4afff6a"; +}) {}; +rel20weechat = rel20.weechat.override { + configure = { availablePlugins, ... }: { + # plugins = with availablePlugins; [ python perl guile ]; + scripts = with pkgs.weechatScripts; [ wee-slack ]; + }; + }; +#+end_src + +First ~rel20~ pin a nixpkgs some specific commit of nix packages. +Second, I overriden the default packages of the =weechat= package. + +Another interresting one is this block: + +#+begin_src nix +let + ... + rel19 = import (fetchGit { + name = "nixpkgs19"; + url = "https://github.com/NixOS/nixpkgs"; + ref = "refs/heads/nixpkgs-19.09-darwin"; + rev = "2f9bafaca90acd010cccd0e79e5f27aa7537957e"; + }) {}; + haskellDeps = ps: with ps; [ + base + protolude + tidal + shake + rel19.haskellPackages.sws + ]; + ghc = pkgs.haskellPackages.ghcWithPackages haskellDeps; + ... +in + home.packages = with pkgs; [ + ... + ghc + ... + ] +#+end_src + +So it means I want to install =ghc= the main Haskell compiler. +But also with some specific haskell packages. +The interresting part, is that in most classical OS environment if you want +a package from a specific language platform. +You need to install the package manager for this language (npm, pip, +etc...). +And in =nixpkgs= there are formulae for most of these language specific +packages. +So instead of just installing =cabal-install= and then installing the +packages I need. +Which could also go bad, because they might be upgraded and not be +compatible all at the same time. + +I used nix to install the packages I needed. +And one interresting detail. +One package [[https://hackage.haskell.org/package/sws][=sws=]] is broken in 20.03 on darwin. +So I used the older version from 19.09. + +[fn:desktop]: I'm using macOS, and I have multiple macs. +A laptop and two desktop machines. +Using the 27" iMac is my ultimate work station. +It really enhance my productivity. +Still the laptop is a superior work environment for more casual tasks. +I guess I might write someday about my full work environment. + + From 35f24f831de76bd158bca9d31ef866ab5833a4e1 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Sun, 14 Jun 2020 23:52:09 +0200 Subject: [PATCH 2/6] updated colors and CSS --- engine/compresscss.sh | 3 +- src/css/y.css | 86 +++++--- src/drafts/XXXX-how-i-use-nix/index.org | 260 ++++++++++++++---------- 3 files changed, 209 insertions(+), 140 deletions(-) diff --git a/engine/compresscss.sh b/engine/compresscss.sh index 763a779..3c4670f 100755 --- a/engine/compresscss.sh +++ b/engine/compresscss.sh @@ -1,7 +1,8 @@ #!/usr/bin/env nix-shell +#!nix-shell --pure #!nix-shell -i bash #!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz" -#!nix-shell -p minify +#!nix-shell -p bash minify # nix-shell -p nodePackages.clean-css diff --git a/src/css/y.css b/src/css/y.css index 7fb425a..a3f61fe 100644 --- a/src/css/y.css +++ b/src/css/y.css @@ -112,7 +112,7 @@ html { } body { - font-family: "American Typewriter", Georgia, Cambria, 'Times New Roman', Times, serif; + font-family: "American Typewriter", Georgia, serif; line-height: 1.5; max-width: 60ch; @@ -125,7 +125,7 @@ body { counter-reset: definition; color: hsl(0, 5%, 10%); - background-color: hsl(210, 20%, 98%); + background-color: hsl(218, 20%, 98%); text-rendering: optimizeLegibility; } @@ -144,12 +144,6 @@ a:not([class]) { text-decoration-skip-ink: auto; } -/* Make links red */ -a, -a:visited { - color: #a00; -} - /* Make images easier to work with */ img { max-width: 100%; @@ -181,12 +175,12 @@ kbd { font-family: Courier, monospace; } pre { - padding: 1rem 1.4rem; + padding: 1rem; max-width: 100%; overflow: auto; - border: 1px solid hsl(210, 15%, 49%); + border: 1px solid hsl(218, 15%, 49%); border-radius: 4px; - background: hsl(210, 40%, 96%); + background: hsl(218, 40%, 96%); font-size: 85%; } pre code { @@ -194,8 +188,8 @@ pre code { position: relative; } kbd { - background: hsl(210, 5%, 100%); - border: 1px solid hsl(210, 5%, 70%); + background: hsl(218, 5%, 100%); + border: 1px solid hsl(218, 5%, 70%); border-radius: 2px; padding: 2px 4px; font-size: 75%; @@ -238,8 +232,9 @@ nav li { } /* Center definitions (most useful for display equations) */ +dl dt { font-weight: 700; } dl dd { - text-align: center; + padding-left: 3rem; } /* Theorem */ @@ -414,6 +409,8 @@ body>input { display: none; } #labels > .content { margin: 0 auto; text-align: center; } label { font-weight: 700; } label:hover { cursor: pointer; } +label ~ pre { margin-top: 0; } +.org-src-container { margin: 1rem 0; } #logo { text-align: center; } body { margin:0; padding: 0; border: 0; max-width: none;} #preamble, #postamble { text-align: center; } @@ -426,7 +423,13 @@ figure img { width: 100%; } .footdef > sup { vertical-align: top; font-size: medium; } .footdef > sup > a { padding: 0.5em; } .footpara { display: inline; } -footer { margin: 3em 0; padding: 1em 0; border-top: solid 1px; border-bottom: solid 1px; line-height: 1em; } +footer { margin: 3em 0; + padding: 1em 0; + border-top: solid 1px; + border-bottom: solid 1px; + line-height: 1em; + font-size: 0.85em; + } td { border-bottom: none; padding: .2rem; } table { margin-top: 1rem; } nav { text-align: center; padding: 2em 0; } @@ -458,24 +461,32 @@ pre { line-height: 1em; } --fg0: var(--b0); --fg: var(--b02); --rfg: #000; - --hl: var(--o); + --hl: var(--r); } /* dark preferred */ @media (prefers-color-scheme: dark) { :root { - --bg: hsl(210,20%,11%); + --bg: hsl(218,20%,16%); --rbg: var(--b03); - --fg: var(--b1); + --fg: var(--b0); --fg0: var(--b00); --rfg: var(--b2); --hl: var(--g); + --y: #ae8c51; + --o: #a9654a; + --r: #af6255; + --m: #ae5e7d; + --v: #6774b2; + --b: #3f8cc3; + --c: #15a198; + --g: #939452; } img { filter: brightness(0.7) saturate(0.5); } pre { - background: hsl(210,40%,15%); - border-color: hsl(210,15%,43%); + background: hsl(218,20%,18%); + border-color: hsl(218,15%,23%); } } @@ -487,30 +498,53 @@ input#l:checked ~ div { --fg: var(--b02); --rfg: #000; --hl: var(--o); + --y: #c18600; + --o: #d84100; + --r: #e62729; + --m: #ec0085; + --v: #6c71c4; + --b: #0095ff; + --c: #00b0a3; + --g: #879a00; } input#l:checked ~ div img { filter: none; } input#l:checked ~ div pre { - border: 1px solid hsl(210, 15%, 49%); - background: hsl(210, 40%, 96%); + border: 1px solid hsl(218, 15%, 49%); + background: hsl(218, 40%, 96%); } /* dark checked */ input#d:checked ~ div { - --bg: hsl(210,20%,11%); + --bg: hsl(218,20%,16%); --rbg: var(--b03); - --fg: var(--b1); + --fg: var(--b0); --fg0: var(--b00); --rfg: var(--b2); --hl: var(--g); + --y: #ae8c51; + --o: #a9654a; + --r: #af6255; + --m: #ae5e7d; + --v: #6774b2; + --b: #3f8cc3; + --c: #15a198; + --g: #939452; } input#d:checked ~ div img { filter: brightness(0.7) saturate(0.5); } input#d:checked ~ div pre { - background: hsl(210,40%,15%); - border-color: hsl(210,15%,43%); + background: hsl(218,20%,18%); + border-color: hsl(218,15%,23%); +} + +/* ---- */ +::selection { + background: var(--m); + color: hsl(218,40%,96%); + text-decoration: hsl(218,40%,96%); } body, body > div { diff --git a/src/drafts/XXXX-how-i-use-nix/index.org b/src/drafts/XXXX-how-i-use-nix/index.org index 1715512..329a98a 100644 --- a/src/drafts/XXXX-how-i-use-nix/index.org +++ b/src/drafts/XXXX-how-i-use-nix/index.org @@ -11,118 +11,163 @@ #+OPTIONS: H:5 auto-id:t toc:nil #+STARTUP: showeverything -In this article I'll explain how I use nix. -I don't use NixOS nor any Linux as my main desktop environment[fn:desktop]. -Still I use [[https://nixos.org/nix][nix]] on a few mac computers. -It has multiple usages. +Have you ever written a small script and you update your system and this +stop working? +Have you copied your tool/script to another machine it doesn't work because +some dependency is missing? +Have you tried to sync your dotfiles to another env and there are a few +details not working? Some missing dependency? +If the answer is yes, then [[https://nixos.org/nix][nix]] can help. -First, let's start by the bad news. -Recent macOS security policy made nix a bit harder to install on a mac. -See [[https://hydra.nixos.org/build/119559243/download/1/manual/#sect-macos-installation][macOS Installation instructions]]. +** Scripts +:PROPERTIES: +:CUSTOM_ID: scripts +:END: -Once you have nix installed you should update the nix-channel. -Mainly a nix-channels is where are the definitions of all the packages. -See [[https://hydra.nixos.org/build/119559243/download/1/manual/#sec-channels][nixOS documentation]]. +Suppose you want to write a portable script. +For example, the script I use to minify my CSS. +Here it is: + +#+begin_src shell +#!/usr/bin/env nix-shell +#!nix-shell --pure +#!nix-shell -i bash +#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz" +#!nix-shell -p bash minify + +minify "$1" > "$2" +#+end_src + +So let's analyze each line of the header block: + +- ~#!/usr/bin/env nix-shell~ :: basic, use ~nix-shell~ to run the script. +- ~#!nix-shell --pure~ :: only use dependencies installed in this nix shell + environment. A bit as if the PATH environment variable was emptied. +- ~#!nix-shell -i bash~ :: tell ~nix-shell~ to run ~bash~ +- ~#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"~ :: + pin the nixpkgs using this archive. +- ~#!nix-shell -p bash minify~ :: install ~bash~ and ~minify~ in the nix shell. + +Now if the script is run on a machine with ~nix~ installed you can be +pretty sure it will work as expected. +Even if I update my OS and I forget about this script for a few years. +As long as I can install nix on the new system and I could download the tar +file the script will be run the same way as the day I wrote it. + +** Temporary working env +:PROPERTIES: +:CUSTOM_ID: temporary-working-env +:END: + +Quite often, I need to do something, and run a specific command that need +me to install a very specific command. +And I'm pretty sure I will not use this tool ever again. + +For those cases, what I do, is generally run my command directly with a +fresh ~nix-shell~. + +#+begin_src shell +> nix-shell -p httpie +[nix-shell:~]$ ... here I can use httpie ... +#+end_src ** Home Manager :PROPERTIES: :CUSTOM_ID: home-manager :END: -First, I use [[https://github.com/rycee/home-manager][home-manager]], it's first usage it to list a reproductible list -of application I need on all my desktop environments. -So i edit the file =~/.config/nixpkgs/home.nix=. -I provide a list of packages I want to have when I start a new shell. +A few years ago I used =brew= to install the tools I need. +With =nix= you can install a new tool with ~nix-env -i~ instead of ~brew install~. +Still recently I prefer to use [[https://github.com/rycee/home-manager][home-manager]]. +The main advantage is that it is even more reproductible and can easily be +shared accross different machines. + +Mainly when I need a new binary I add it in a description list in the file +=~/.config/nixpkgs/home.nix=. +It looks like this: #+begin_src nix - home.packages = with pkgs; [ - # nix - nix-prefetch-git - lorri - # emacs - emacsMacport - imagemagick - gnupg - # vim - neovim - # shell - direnv - fasd - fd - findutils - fortune - gawk - git - gitAndTools.diff-so-fancy - graphviz - htop - httpie - jq - jwt-cli - libressl - mustache-go - pandoc - ripgrep - rtv - wakatime - xpdf # pdftotext - yadm - youtube-dl - # clojure - leiningen - boot - adoptopenjdk-bin - joker - # Haskell - ghc - cabal-install - (all-hies.selection - { selector = p: - { inherit (p) ghc865; };}) - # Common LISP - sbcl - # mails - offlineimap - notmuch - msmtp - gmailieer - # docker - docker-compose - # weechat - rel20weechat - aspell - aspellDicts.en - aspellDicts.fr - ]; +home.packages = with pkgs; [ + # emacs + emacsMacport + imagemagick + gnupg + # shell + direnv + ... +]; #+end_src +then I simply run ~home-manager switch~ and I've got all those tools in my env. + +*** Pinning the packages +:PROPERTIES: +:CUSTOM_ID: pinning-the-packages +:END: + +#+begin_src nix +{ config, pkgs, ... }: +let + # ... + pkgs = import (fetchGit { + name = "nixpkgs20"; + url = "https://github.com/NixOS/nixpkgs"; + # obtained via + # git ls-remote https://github.com/NixOS/nixpkgs nixpkgs-20.03-darwin + ref = "refs/heads/nixpkgs-20.03-darwin"; + rev = "58f884cd3d89f47672e649c6edfb2382d4afff6a"; + }) {}; + # ... +in { + # ... +} +#+end_src + +*** Specific tools +:PROPERTIES: +:CUSTOM_ID: specific-tools +:END: + There are a few noticiable artifact here: -The first one is ~rel20weechat~ is a very specify build of weechat with the +The first one is ~weechat~ is a very specify build of weechat with the plugin I need. So here is the block I use: #+begin_src nix -rel20 = import (fetchGit { - name = "nixpkgs20"; - url = "https://github.com/NixOS/nixpkgs"; - # obtained via - # git ls-remote https://github.com/NixOS/nixpkgs nixpkgs-20.03-darwin - ref = "refs/heads/nixpkgs-20.03-darwin"; - rev = "58f884cd3d89f47672e649c6edfb2382d4afff6a"; -}) {}; -rel20weechat = rel20.weechat.override { - configure = { availablePlugins, ... }: { - # plugins = with availablePlugins; [ python perl guile ]; - scripts = with pkgs.weechatScripts; [ wee-slack ]; +let + ... + rel20weechat = rel20.weechat.override { + configure = { availablePlugins, ... }: { + # plugins = with availablePlugins; [ python perl guile ]; + scripts = with pkgs.weechatScripts; [ wee-slack ]; + }; }; - }; + ... +in +{ + ... + home.packages = with pkgs; [... rel20weechat ...]; + ... +} #+end_src First ~rel20~ pin a nixpkgs some specific commit of nix packages. Second, I overriden the default packages of the =weechat= package. -Another interresting one is this block: +*** Another nice tool is =sws= +:PROPERTIES: +:CUSTOM_ID: another-nice-tool-is--sws- +:END: + +I use macOS so even though I'm using a darwin focused nixpkgs +sometimes a few package can be broken and can't be installed. + + +That occurred with [[https://hackage.haskell.org/package/sws][=sws=]] during the upgrade to 20.03 on darwin. +This is a simple tool that need haskell to be compiled locally and +installed. +Here is how I could install it: #+begin_src nix let @@ -133,46 +178,35 @@ let ref = "refs/heads/nixpkgs-19.09-darwin"; rev = "2f9bafaca90acd010cccd0e79e5f27aa7537957e"; }) {}; - haskellDeps = ps: with ps; [ - base - protolude - tidal - shake - rel19.haskellPackages.sws - ]; - ghc = pkgs.haskellPackages.ghcWithPackages haskellDeps; ... in home.packages = with pkgs; [ ... ghc + rel19.haskellPackages.sws ... ] #+end_src -So it means I want to install =ghc= the main Haskell compiler. -But also with some specific haskell packages. -The interresting part, is that in most classical OS environment if you want -a package from a specific language platform. -You need to install the package manager for this language (npm, pip, -etc...). -And in =nixpkgs= there are formulae for most of these language specific -packages. -So instead of just installing =cabal-install= and then installing the -packages I need. -Which could also go bad, because they might be upgraded and not be -compatible all at the same time. - -I used nix to install the packages I needed. -And one interresting detail. -One package [[https://hackage.haskell.org/package/sws][=sws=]] is broken in 20.03 on darwin. So I used the older version from 19.09. [fn:desktop]: I'm using macOS, and I have multiple macs. A laptop and two desktop machines. -Using the 27" iMac is my ultimate work station. +Using the 27″ iMac is my ultimate work station. It really enhance my productivity. Still the laptop is a superior work environment for more casual tasks. I guess I might write someday about my full work environment. +** Install +:PROPERTIES: +:CUSTOM_ID: install +:END: + +First, let's start by the bad news. +Recent macOS security policy made nix a bit harder to install on a mac. +See [[https://hydra.nixos.org/build/119559243/download/1/manual/#sect-macos-installation][macOS Installation instructions]]. + +Once you have nix installed you should update the nix-channel. +Mainly a nix-channels is where are the definitions of all the packages. +See [[https://hydra.nixos.org/build/119559243/download/1/manual/#sec-channels][nixOS documentation]]. From 9eb7ecb8ef916a36fdaab89707a06fb6c264bb2c Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Mon, 15 Jun 2020 00:02:26 +0200 Subject: [PATCH 3/6] save --- src/drafts/XXXX-how-i-use-nix/index.org | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/drafts/XXXX-how-i-use-nix/index.org b/src/drafts/XXXX-how-i-use-nix/index.org index 329a98a..13ee071 100644 --- a/src/drafts/XXXX-how-i-use-nix/index.org +++ b/src/drafts/XXXX-how-i-use-nix/index.org @@ -54,6 +54,10 @@ Even if I update my OS and I forget about this script for a few years. As long as I can install nix on the new system and I could download the tar file the script will be run the same way as the day I wrote it. +**Remark**: +You can use any shell (like ~fish~, ~zsh~) but also other languages +~python~, ~haskell~, etc... + ** Temporary working env :PROPERTIES: :CUSTOM_ID: temporary-working-env @@ -132,12 +136,13 @@ in { There are a few noticiable artifact here: The first one is ~weechat~ is a very specify build of weechat with the -plugin I need. So here is the block I use: +plugin I need. +So here is the block I use: #+begin_src nix let ... - rel20weechat = rel20.weechat.override { + weechat-with-weeslack = weechat.override { configure = { availablePlugins, ... }: { # plugins = with availablePlugins; [ python perl guile ]; scripts = with pkgs.weechatScripts; [ wee-slack ]; @@ -147,13 +152,15 @@ let in { ... - home.packages = with pkgs; [... rel20weechat ...]; + home.packages = with pkgs; [... weechat-with-wee-slack ...]; ... } #+end_src -First ~rel20~ pin a nixpkgs some specific commit of nix packages. -Second, I overriden the default packages of the =weechat= package. +Even if this looks cryptic. +The important detail is just that there exists a way to say to nix I'd like +to use weechat (an IRC client) with the wee-slack client (which uses python). +And nix handle the rest for me. *** Another nice tool is =sws= :PROPERTIES: @@ -163,7 +170,6 @@ Second, I overriden the default packages of the =weechat= package. I use macOS so even though I'm using a darwin focused nixpkgs sometimes a few package can be broken and can't be installed. - That occurred with [[https://hackage.haskell.org/package/sws][=sws=]] during the upgrade to 20.03 on darwin. This is a simple tool that need haskell to be compiled locally and installed. From e3f7c5c0bd6e977cb5904d47bd90cbfa13c03ac8 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Mon, 15 Jun 2020 00:45:51 +0200 Subject: [PATCH 4/6] wip --- src/drafts/XXXX-how-i-use-nix/index.org | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/drafts/XXXX-how-i-use-nix/index.org b/src/drafts/XXXX-how-i-use-nix/index.org index 13ee071..e1eb7fb 100644 --- a/src/drafts/XXXX-how-i-use-nix/index.org +++ b/src/drafts/XXXX-how-i-use-nix/index.org @@ -75,6 +75,9 @@ fresh ~nix-shell~. [nix-shell:~]$ ... here I can use httpie ... #+end_src +If I don't use ~httpie~ for a while it will be garbage collected +eventually. + ** Home Manager :PROPERTIES: :CUSTOM_ID: home-manager From 05314b7001c20e8808d4d8c8893efeb817c56f5c Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Wed, 17 Jun 2020 00:10:49 +0200 Subject: [PATCH 5/6] update for the new blog post. --- src/css/y.css | 6 +- .../com.github.target.lorri.plist | 23 +++ src/drafts/XXXX-how-i-use-nix/index.org | 140 +++++++++++++++--- 3 files changed, 143 insertions(+), 26 deletions(-) create mode 100644 src/drafts/XXXX-how-i-use-nix/com.github.target.lorri.plist diff --git a/src/css/y.css b/src/css/y.css index a3f61fe..e317e2c 100644 --- a/src/css/y.css +++ b/src/css/y.css @@ -302,6 +302,7 @@ dl dd { } /* Make footnote text smaller and left align it (looks bad with long URLs) */ +.footref { display: inline-block; padding: 0 3px; } .footnotes p { text-align: left; line-height: 1.5; @@ -556,13 +557,14 @@ a,a:visited { color: var(--hl); } /* ---- SYNTAX HIGHLIGHTING ---- */ #table-of-contents { text-align: left; } .org-rainbow-delimiters-depth-1, .org-rainbow-delimiters-depth-9, -.org-css-selector, .org-nix-attribute, .org-builtin, +.org-css-selector, .org-builtin, .IN_REVIEW { color:var(--c); } .org-rainbow-delimiters-depth-2, .org-nix-builtin, .org-variable-name, -.org-haskell-definition, .org-haskell-operator, .org-function-name, .org-diff-changed { +.org-haskell-definition, .org-haskell-operator, .org-function-name, .org-diff-changed, +.org-nix-attribute, .org-nxml-element-local-name { color:var(--b); } diff --git a/src/drafts/XXXX-how-i-use-nix/com.github.target.lorri.plist b/src/drafts/XXXX-how-i-use-nix/com.github.target.lorri.plist new file mode 100644 index 0000000..1381526 --- /dev/null +++ b/src/drafts/XXXX-how-i-use-nix/com.github.target.lorri.plist @@ -0,0 +1,23 @@ + + + + + Label + com.github.target.lorri + ProgramArguments + + /bin/zsh + -i + -c + $HOME/.nix-profile/bin/lorri daemon + + StandardOutPath + /var/tmp/lorri.log + StandardErrorPath + /var/tmp/lorri.log + RunAtLoad + + KeepAlive + + + diff --git a/src/drafts/XXXX-how-i-use-nix/index.org b/src/drafts/XXXX-how-i-use-nix/index.org index e1eb7fb..ef44c01 100644 --- a/src/drafts/XXXX-how-i-use-nix/index.org +++ b/src/drafts/XXXX-how-i-use-nix/index.org @@ -136,34 +136,35 @@ in { :CUSTOM_ID: specific-tools :END: -There are a few noticiable artifact here: +There are a few noticiable artifacts here: The first one is ~weechat~ is a very specify build of weechat with the plugin I need. -So here is the block I use: +For that I created a new directory =weechat-with-weeslack= containing a +=default.nix=: #+begin_src nix -let - ... - weechat-with-weeslack = weechat.override { - configure = { availablePlugins, ... }: { - # plugins = with availablePlugins; [ python perl guile ]; - scripts = with pkgs.weechatScripts; [ wee-slack ]; - }; - }; - ... -in -{ - ... - home.packages = with pkgs; [... weechat-with-wee-slack ...]; - ... +{ pkgs, ...}: +pkgs.weechat.override { + configure = { availablePlugins, ... }: { + # plugins = with availablePlugins; [ python perl guile ]; + scripts = with pkgs.weechatScripts; [ wee-slack ]; + }; } #+end_src +And in my =home.nix= I use: + +#+begin_src nix + weechat-with-weeslack = import ./weechat-with-weeslack { + inherit pkgs; + }; +#+end_src + Even if this looks cryptic. The important detail is just that there exists a way to say to nix I'd like to use weechat (an IRC client) with the wee-slack client (which uses python). -And nix handle the rest for me. +And nix handle the rest for me without any conflict. *** Another nice tool is =sws= :PROPERTIES: @@ -187,30 +188,121 @@ let ref = "refs/heads/nixpkgs-19.09-darwin"; rev = "2f9bafaca90acd010cccd0e79e5f27aa7537957e"; }) {}; + haskellDeps = ps: with ps; [ + base + protolude + tidal + shake + rel19.haskellPackages.sws + ]; + ghc = pkgs.haskellPackages.ghcWithPackages haskellDeps; ... in home.packages = with pkgs; [ ... ghc - rel19.haskellPackages.sws ... ] #+end_src So I used the older version from 19.09. -[fn:desktop]: I'm using macOS, and I have multiple macs. -A laptop and two desktop machines. -Using the 27″ iMac is my ultimate work station. -It really enhance my productivity. -Still the laptop is a superior work environment for more casual tasks. -I guess I might write someday about my full work environment. +** Dev environment +:PROPERTIES: +:CUSTOM_ID: dev-environment +:END: + +When working on a project. +You can produce a pretty good local environment. +For example, for my blog, I only use emacs and a few shell scripts. +Still I needed to fix a few binaries, like the correct ~date~ via +~coreutils~. +And also I use ~html-xml-utils~ to easily deal with html/xml parsing. +I use it to generate my RSS xml file. + +So I have a ~shell.nix~ files at the root of my project: + +#+begin_src nix +{ pkgs ? import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz) {} }: + let my_aspell = pkgs.aspellWithDicts(p: with p; [en fr]); + in + pkgs.mkShell { + buildInputs = [ pkgs.coreutils + pkgs.html-xml-utils + pkgs.zsh + pkgs.perl + pkgs.perlPackages.URI + pkgs.minify + pkgs.haskellPackages.sws + pkgs.cacert + ]; + } +#+end_src + +So I just need to launch ~nix-shell~ and I have my environment. + +A nice addition is to use direnv[fn:direnv] which support ~nix-shell~ by putting +~use_nix~ inside the ~.envrc~ at the root of the project. +But by default invoking ~nix-shell~ can take a few seconds everytime. +But we can do even better by using lorri[fn:lorri]. +I start the lorri daemon in my ~StartupItems~ mainly I simply created +the file =~/Library/LaunchAgents/com.github.target.lorri.plist=: + +#+begin_src xml :tangle com.github.target.lorri.plist :mkdirp t + + + + + Label + com.github.target.lorri + ProgramArguments + + /bin/zsh + -i + -c + $HOME/.nix-profile/bin/lorri daemon + + StandardOutPath + /var/tmp/lorri.log + StandardErrorPath + /var/tmp/lorri.log + RunAtLoad + + KeepAlive + + + +#+end_src + +And started the daemon with: + +#+begin_src bash +launchctl load ~/Library/LaunchAgents/com.github.target.lorri.plist +#+end_src + +~lorri~ takes care of keeping a cache and watch my configuration change by +project. +This makes the call to ~direnv~ almost instantaneous and seemless. +I just changed the content of my ~.envrc~ with: + +#+begin_src shell +eval "$(lorri direnv)" +#+end_src + +And of course this would work the same way with more complex ~shell.nix~. +Typically for Haskell projects. + +[fn:direnv] https://direnv.net +[fn:lorri] https://github.com/target/lorri + ** Install :PROPERTIES: :CUSTOM_ID: install :END: +So you would like to use nix too? + First, let's start by the bad news. Recent macOS security policy made nix a bit harder to install on a mac. See [[https://hydra.nixos.org/build/119559243/download/1/manual/#sect-macos-installation][macOS Installation instructions]]. From d6223ad3d42bbfc35508582d2828338329e8e302 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Sat, 20 Jun 2020 19:52:08 +0200 Subject: [PATCH 6/6] minor css fix --- engine/serve.sh | 2 +- project.el | 2 +- project.el.sig | Bin 586 -> 586 bytes src/css/y.css | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/serve.sh b/engine/serve.sh index 2cfcd1b..fe058eb 100755 --- a/engine/serve.sh +++ b/engine/serve.sh @@ -10,4 +10,4 @@ fi cd $webdir && \ echo "Serving: $webdir" && \ -sws -d --port 3001 . +sws -d --port 3000 . diff --git a/project.el b/project.el index 2db93e5..aa805d5 100644 --- a/project.el +++ b/project.el @@ -284,7 +284,7 @@ " %s" ;; source " -sampling-factor 4:2:0" " -strip" - " -resize 200x200\\>" + " -resize 320x320\\>" " -interlace Plane" " -quality 85" " -define filter:blur=0.75" diff --git a/project.el.sig b/project.el.sig index f71b3f13b0984aa00b6df39e4fb0e01b1d50cee7..9f341867d4ee9111a0d0f6b359d58d56a822506b 100644 GIT binary patch delta 534 zcmV+x0_pwA1j+=EBLnV9W058xe=sZ$`vj^WX=y6IhmI24MxvMQXX8C@%S!qPqsQDn z=bpWV<+gUuq?E!mC82wlZ_REU2a%cnBrn6RLl>>Kg4L%|b{O;jF!EFlt@O_|``ICb zSf}99`rILfyX>)Gy`~nTb-E7y(`$NVbgD}f1;#~Wa)e46+ELf!TfmhSe*hNp5n^1( zj>nF3YV_iX28he#vV`3f>|)2=2xt_d$~B6Pc2Y17GZ13sxksU3${^~ef|airkxiEfZUZ-Ea4C^qpR1wk!P3vW6l3*afe$^0oLck_e zn&1`0pT<{$^HO0srdQO$I{Az=HHc-iQ&RH-ff>i_@% delta 534 zcmV+x0_pwA1j+=EBLm9=hmj^Ae}#b%0KIcY2Uqf72N)jDQY}FgMYw4s%!d{@Pn#Ix z>UAMUt})V7SAiGE{-6iechzXWbK@$iaoD^_ayA%tE4;qPMlrhe;ObzBE?OA9ky)EO zkZbCRtU4`Wc@tY~IWtK z=HEaI>aMTzIgd9RBnhPU-Vd%EUEWXtCL&PmMo+4wa7s}-4QB% zjE^{;)|_(IA18Z1eVmKL;^SON1yGPK4uGFf%^$Y<6zin%()Y4QM5|;F*5Ez8^BzFW zIE`nw-`oz{Nf#h3u^PpD?Y0icBq2neHo;g7Qi6yk&?vCViZS3!e+>qNVES>GSG*D$ zL2J^l5(=BG=v|b~xxLlxlll$xDVm}G3y$