Skip to content

Instantly share code, notes, and snippets.

@cleverca22
cleverca22 / configuration.nix
Last active February 5, 2024 00:06
NixOS virtualbox guest additions
# ...
virtualisation.virtualbox.guest.enable = true;
nixpkgs.config.packageOverrides = pkgs: {
linuxPackages = pkgs.linuxPackages // {
virtualboxGuestAdditions = pkgs.callPackage ./virtualbox-guest.nix {};
};
};
# ...
start:
alias FlushSwitch d0
alias FlushRegulator d1
alias Furnace d2
alias FillSwitch d3
alias FillRegulator d4
loop:
l r0 FillSwitch Open
s FillRegulator On r0
l r0 FlushSwitch Open
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
inherit (lib) optional optionals;
erlang = pkgs.beam.interpreters.erlangR24;
elixir = pkgs.beam.packages.erlangR24.elixir_1_13;
nodejs = pkgs.nodejs-18_x;
mkdir -pv $out/repository/{$DIR1,$DIR2}
function tryfetch {
if [ ! -e "$2" ] ; then
echo trying "$1"
curl -fk "$1" > "$2" || (echo failed; rm "$2")
else
true
fi
}
for mirror in $mirrors; do
[root@laptop:~]# nix-instantiate '<nixos>' -A system
waiting for the big garbage collector lock...
warning: you did not specify ‘--add-root’; the result might be removed by the garbage collector
/nix/store/gjyr1f2mp052bdh4j6vxy95m8jl7s04w-nixos-system-laptop-16.09pre82105.7465bcd.drv
[clever@laptop:~]$ nix-copy-closure --to root@amd /nix/store/gjyr1f2mp052bdh4j6vxy95m8jl7s04w-nixos-system-laptop-16.09pre82105.7465bcd.drv
Password:
copying 241 missing paths (3.87 MiB) to ‘root@amd’...
[clever@amd-nixos:~]$ nix-copy-closure --to root@router /nix/store/gjyr1f2mp052bdh4j6vxy95m8jl7s04w-nixos-system-laptop-16.09pre82105.7465bcd.drv
@cleverca22
cleverca22 / Main.hs
Created July 26, 2021 18:27
New Project
{-# LANGUAGE OverloadedStrings #-}
module Escrow where
import Language.Marlowe.Extended
main :: IO ()
main = print . pretty $ contract
-- We can set explicitRefunds True to run Close refund analysis
-- but we get a shorter contract if we set it to False
{config,pkgs,...}:
let
myVim = pkgs.vim_configurable.customize {
name = "vim";
vimrcConfig = {
customRC = ''
syntax on
set nu
set foldmethod=syntax
rec {
test1 = builtins.scopedImport { __nixPath = [ { path = test4; prefix="ssh-config-file"; } ] ++ __nixPath; };
test2 = test1 <nixpkgs/pkgs/build-support/fetchgit/private.nix>;
pkgs = import <nixpkgs> {};
test3 = pkgs.callPackage test2 {};
test4 = pkgs.writeText "sshd_config" ''
# empty file, use programs.ssh.knownHosts in configuration.nix not StrictHostKeyChecking no
'';
test5 = test3 {
url = "git@github.com:cleverca22/not-os.git";
@cleverca22
cleverca22 / Glut.hs
Created October 6, 2019 20:30 — forked from kindaro/Glut.hs
import System.Exit (exitWith, ExitCode(ExitSuccess))
import Graphics.UI.GLUT
main = do
(progName, _args) <- getArgsAndInitialize
initialDisplayMode $= [ SingleBuffered, RGBMode ]
initialWindowSize $= Size 500 500
_ <- createWindow progName
exitWith ExitSuccess
@cleverca22
cleverca22 / 32bit-simple-test.nix
Last active September 8, 2019 12:43
patchelf util
with import <nixpkgs> { system = "i686-linux"; };
runCommandCC "filename" { buildInputs = [ gcc ]; } ''
cat <<EOF > $out
#!${stdenv.shell}
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath ${lib.makeLibraryPath [ zlib ]} \$1
EOF
chmod +x $out
''