mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 01:57:54 +00:00
33 lines
7.8 KiB
HTML
33 lines
7.8 KiB
HTML
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>Reproducible executables with Nix</title><script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async="" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script><script type="text/x-mathjax-config">
|
|
MathJax = {
|
|
tex: {
|
|
inlineMath: [ ['$','$'], ['\(','\)'] ],
|
|
displayMath: [ ['$$','$$'], ['[',']'] ]
|
|
},
|
|
options = {
|
|
processHtmlClass = "math"
|
|
}
|
|
}
|
|
</script><meta name="next-head-count" content="6"/><link rel="preload" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" as="style"/><link rel="stylesheet" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" data-n-g=""/><noscript data-n-css=""></noscript><link rel="preload" href="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" as="script"/></head><body><div id="__next"><main><h1>Reproducible executables with Nix</h1><section class="post-metadata"><span>Date: <!-- -->2021-07-18 22:16:30 +08:00</span><span>Date modified: <!-- -->2021-07-18 22:16:30 +08:00</span></section><nav class="toc"><ol class="toc-level toc-level-1"></ol></nav><p>You can create a <a href="https://nix.dev/tutorials/ad-hoc-developer-environments#reproducible-executables">reproducible executable</a> that only requires Nix.
|
|
</p><p>Here's a sample script that uses multiple dependencies.
|
|
</p><div class="special-block block-tip"><p>If the script interact with the network (e.g., <code class="inline-verbatim">curl</code>, <code class="inline-verbatim">wget</code>) and the environment is completely pure, don't forget to install public Certificate Authorities with <code class="inline-verbatim">cacert</code>.
|
|
</p></div><pre class="src-block"><code class="language-bash">#!/usr/bin/env nix-shell
|
|
#! nix-shell --pure -i bash -p coreutils curl cacert jq fzf findutils
|
|
|
|
# A quick command line interface for creating a gitignore with the API from https://gitignore.io.
|
|
# This script comes with a simple caching to avoid creating too much requests.
|
|
|
|
set -eo pipefail
|
|
|
|
CACHE_FILE="${XDG_CACHE_DIR:-$HOME/.cache}/gitignore-io.langs.json"
|
|
|
|
# Check if the language list is downloaded for the last hour (3600 seconds).
|
|
if [ ! -e $CACHE_FILE ] || test $(expr $(date "+%s") - $(date -r $CACHE_FILE "+%s")) -gt 3600
|
|
then
|
|
ping "gitignore.io" --count 4 && curl --silent --location --output $CACHE_FILE "https://gitignore.io/api/list?format=json"
|
|
fi
|
|
|
|
KEYS=$(jq 'keys | .[] | @text' --raw-output $CACHE_FILE | fzf --multi | while read lang; do echo " .[\"$lang\"].contents"; done | paste -s -d ',')
|
|
|
|
jq "$KEYS" --raw-output $CACHE_FILE
|
|
</code></pre><section><h2>Backlinks</h2><ul><li><a href="/wiki/tools.nix">Nix package manager</a></li></ul></section></main></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"metadata":{"date":"2021-07-18 22:16:30 +08:00","date_modified":"2021-07-18 22:16:30 +08:00","language":"en","source":""},"title":"Reproducible executables with Nix","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can create a "},{"type":"element","tagName":"a","properties":{"href":"https://nix.dev/tutorials/ad-hoc-developer-environments#reproducible-executables"},"children":[{"type":"text","value":"reproducible executable"}]},{"type":"text","value":" that only requires Nix.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's a sample script that uses multiple dependencies.\n"}]},{"type":"element","tagName":"div","properties":{"className":["special-block","block-tip"]},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If the script interact with the network (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"curl"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"wget"}]},{"type":"text","value":") and the environment is completely pure, don't forget to install public Certificate Authorities with "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"cacert"}]},{"type":"text","value":".\n"}]}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"#!/usr/bin/env nix-shell\n#! nix-shell --pure -i bash -p coreutils curl cacert jq fzf findutils\n\n# A quick command line interface for creating a gitignore with the API from https://gitignore.io.\n# This script comes with a simple caching to avoid creating too much requests.\n\nset -eo pipefail\n\nCACHE_FILE=\"${XDG_CACHE_DIR:-$HOME/.cache}/gitignore-io.langs.json\"\n\n# Check if the language list is downloaded for the last hour (3600 seconds).\nif [ ! -e $CACHE_FILE ] || test $(expr $(date \"+%s\") - $(date -r $CACHE_FILE \"+%s\")) -gt 3600\nthen\n ping \"gitignore.io\" --count 4 \u0026\u0026 curl --silent --location --output $CACHE_FILE \"https://gitignore.io/api/list?format=json\"\nfi\n\nKEYS=$(jq 'keys | .[] | @text' --raw-output $CACHE_FILE | fzf --multi | while read lang; do echo \" .[\\\"$lang\\\"].contents\"; done | paste -s -d ',')\n\njq \"$KEYS\" --raw-output $CACHE_FILE\n"}]}]}]},"backlinks":[{"path":"/tools.nix","title":"Nix package manager"}]},"__N_SSG":true},"page":"/[[...slug]]","query":{"slug":["tools.nix.reproducible-executables"]},"buildId":"Ie9t5zutrXP6Of75Cb5xF","assetPrefix":"/wiki","nextExport":false,"isFallback":false,"gsp":true}</script><script nomodule="" src="/wiki/_next/static/chunks/polyfills-99d808df29361cf7ffb1.js"></script><script src="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" async=""></script><script src="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" async=""></script><script src="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" async=""></script><script src="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" async=""></script><script src="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" async=""></script><script src="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" async=""></script><script src="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" async=""></script><script src="/wiki/_next/static/Ie9t5zutrXP6Of75Cb5xF/_buildManifest.js" async=""></script><script src="/wiki/_next/static/Ie9t5zutrXP6Of75Cb5xF/_ssgManifest.js" async=""></script></body></html> |