Skip to content

Instantly share code, notes, and snippets.

View MikaelFangel's full-sized avatar
🎆
NixOS

Mikael Fangel MikaelFangel

🎆
NixOS
View GitHub Profile
@MikaelFangel
MikaelFangel / day1_part2_fixer.sh
Created December 2, 2023 20:00
Advent of Code 2023 - Day 1 Part 2 - Cleaner script to make the file easier to parse
#!/bin/env bash
file=./input.txt
sed -i s/eighthree/83/g $file
sed -i s/eightwo/82/g $file
sed -i s/sevenine/79/g $file
sed -i s/fiveight/58/g $file
sed -i s/threeight/38/g $file
sed -i s/twone/21/g $file
@MikaelFangel
MikaelFangel / flake.nix
Created November 15, 2023 18:21
A simple rust devshell flake for direnv
{
description = "A basic rust devshell flake";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default =
@MikaelFangel
MikaelFangel / flake.nix
Created November 15, 2023 18:18
R development flake for direnv
{
description = "A basic flake with a shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = pkgs.mkShell {
@MikaelFangel
MikaelFangel / flake.nix
Last active November 24, 2023 10:58
Simple F# devshell for direnv
{
description = "F# DevShell";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system:
@MikaelFangel
MikaelFangel / oldclifix.md
Last active October 2, 2023 14:05
HowTo: Use old Nix-Cli on flakyfied system

Fix for one command only

nix-build flake:nixpkgs -A hello
nix-build -I nixpkgs=flake:github:NixOS/nixpkgs/nixos-23.05 '<nixpkgs>' -A hello
NIX_PATH=nixpkgs=flake:nixpkgs nix-build '<nixpkgs>' -A hello

Fix it decleratively

makeWrapper and wrapProgram

Nix generally assumes run-time dependencies is a subset of the build-time dependencies.

This means many Nix builder functions try to automatically scan the output for runtime dependencies and "rewrite" them for runtime usage.

However shell scripts which are often exported by packages do not get this automatic scanning treatment.

This means you have to use the makeWrapper package and use either the makeWrapper or wrapProgram utility functions.

@MikaelFangel
MikaelFangel / read2DCharArray.fs
Last active September 11, 2023 14:46
How to read 2D array from console in F#
open System
// Create a rectangular array of chars
let read2DCharArray rowCount colCount =
let rows = [| for _ in 1 .. rowCount -> Console.ReadLine() |> Array.ofSeq |]
Array2D.init rowCount colCount (fun i j -> rows[i][j])
// Create a jagged array of chars
let read2DCharArrayJagged rows =
[| for _ in 1 .. rows -> Console.ReadLine() |> Array.ofSeq |]
@MikaelFangel
MikaelFangel / lockscreen.sh
Last active April 10, 2023 20:08
Blurred lockscreen using swaybg
#------------------------------------#
# Get the blurred lock screen effect #
# using swaybg, grim and ffmpeg on #
# wayland. #
#------------------------------------#
#!/bin/env bash
path=/tmp/tmpbg.png
pathout=/tmp/tmpbgblur.png
@MikaelFangel
MikaelFangel / null-ls.lua
Created April 9, 2023 20:57
Nvim Go null-ls configuration with lsp, linter and auto imports
local present, null_ls = pcall(require, "null-ls")
if not present then
return
end
local b = null_ls.builtins
local sources = {
b.formatting.gofumpt,
@MikaelFangel
MikaelFangel / search_path.sh
Created February 8, 2023 18:25
Search the path environment variable in bash with find
find $(echo $PATH | sed 's/:/ /g') -type f -name 'ls'