This is an example of a standalone single-file module that outputs a JSON file out of it's configuration.
Standalone in this context means it's not meant to be used by NixOS or Home Manager configurations.
This is an example of a standalone single-file module that outputs a JSON file out of it's configuration.
Standalone in this context means it's not meant to be used by NixOS or Home Manager configurations.
#! /usr/bin/env nix-shell | |
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/cbe419ed4c8f98bd82d169c321d339ea30904f1f.tar.gz --tarball-ttl 4294967295 | |
#! nix-shell -p "haskellPackages.ghcWithPackages (p: with p; [net-mqtt data-default])" | |
#! nix-shell -i "runhaskell -Wall" | |
-- This program builds itself and publishes given message to MQTT broker. | |
-- Copyright (C) 2024 Alexander Tomokhov | |
-- | |
-- This program is free software: you can redistribute it and/or modify | |
-- it under the terms of the GNU General Public License as published by |
EDIT: check out fix-python instead, make Python run "as usual" on NixOS!
#!/usr/bin/env -S bash -c 'nix-shell --pure $0 -A env' | |
# Usage: | |
# 1. run directly to enter bash (inside venv): `./venv-py37.nix` | |
# 2. build a standalone executable: `nix bundle -f ./venv-py37.nix` #this not works yet since it cause nested `unshare -U` call | |
# 3. run bash with extra arguments: `nix run -f ./venv-py37.nix '' -- -c 'python --version'` | |
# More: | |
# 1. commit id of nixpkgs can be found here: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=python3 | |
let |
I wanted to write a module that generates multiple systemd services and timers to scrub some zfs pools at certain intervals. The default scrub config does not support individual scrub intervals for each pool.
I want the config to look like this:
{
services.zfs-auto-scrub = {
tank = "Sat *-*-* 00:00:00";
class Basic { | |
data class Var(val name: String) | |
class Let { | |
infix fun BE(value: Any): Binding = TODO() | |
} | |
class Binding { | |
infix fun MOD(other: Any): Binding = TODO() | |
} |
module Board where | |
import Data.Map (Map, (!)) | |
import qualified Data.Map as Map | |
import Data.List (intercalate) | |
data Player = X | O | |
deriving (Eq, Ord, Show) | |
newtype Board = Board (Map (Int, Int) (Maybe Player)) |
#! /usr/bin/env nix-shell | |
#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [ diagrams-cairo (diagrams.overrideAttrs (def: { buildInputs = def.buildInputs ++ [ diagrams-cairo ]; configureFlags = def.configureFlags ++ [ \"-f cairo\" ]; })) ])" | |
{-# LANGUAGE NoMonomorphismRestriction #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE TypeFamilies #-} | |
-- import Diagrams.Backend.SVG.CmdLine | |
import Diagrams.Backend.Cairo.CmdLine | |
import Diagrams.Prelude |