Skip to content

Instantly share code, notes, and snippets.

@edolstra
edolstra / nix-ui.md
Last active February 2, 2024 23:31
Nix UI

General notes

  • nix-channel and ~/.nix-defexpr are gone. We'll use $NIX_PATH (or user environment specific overrides configured via nix set-path) to look up packages. Since $NIX_PATH supports URLs nowadays, this removes the need for channels: you can just set $NIX_PATH to e.g. https://nixos.org/channels/nixos-15.09/nixexprs.tar.xz and stay up to date automatically.

  • By default, packages are selected by attribute name, rather than the name attribute. Thus nix install hello is basically equivalent to nix-env -iA hello. The attribute name is recorded in the user environment manifest and used in upgrades. Thus (at least by default) hello won't be upgraded to helloVariant.

    @vcunat suggested making this an arbitrary Nix expression rather than an attrpath, e.g. firefox.override { enableFoo = true; }. However, such an expression would not have a key in the user environment, unlike an attrpath. Better to require an explicit flag for this.

TBD: How to deal with search path clashes.

@3noch
3noch / Geolocation.hs
Last active January 30, 2016 20:25
Reflex-DOM Geolocation
module Geoposition where
import Control.Concurrent (forkIO)
import Control.Monad.Exception (catch, throw)
import Control.Monad.IO.Class (liftIO)
import Reflex (Event)
import Reflex.Dom (MonadWidget)
import Reflex.Dom.Class (performEventAsync)
@vasanthk
vasanthk / System Design.md
Last active May 31, 2024 01:39
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@roelvandijk
roelvandijk / Nub.hs
Last active February 7, 2016 16:51 — forked from fizruk/Nub.hs
Incredibly slow type-level Nub
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Nub where
import Data.Proxy
import Data.Type.Bool
@martijnvermaat
martijnvermaat / nixos.md
Last active May 9, 2024 01:11
Installation of NixOS with encrypted root
@aisamanra
aisamanra / simple_hans_server.hs
Created June 1, 2016 06:09
A basic application written using ssh-hans
module Main where
{-
Here is a real---if not particularly interesting---interaction with this server:
[gdritter@armilla ~]$ ssh -p 9999 localhost incr
ok.
[gdritter@armilla ~]$ ssh -p 9999 localhost incr
ok.
[gdritter@armilla ~]$ ssh -p 9999 localhost double
@phadej
phadej / poly-nfdata.hs
Last active November 6, 2017 22:24
Example how is possible to write polykinded type-classes in GHC-8.0. It's not that bad or messy, but I'm not sure it's practical either.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
@Icelandjack
Icelandjack / Constraints.org
Last active April 2, 2024 20:22
Type Classes and Constraints

Reddit discussion.

Disclaimer 1: Type classes are great but they are not the right tool for every job. Enjoy some balance and balance to your balance.

Disclaimer 2: I should tidy this up but probably won’t.

Disclaimer 3: Yeah called it, better to be realistic.

Type classes are a language of their own, this is an attempt to document features and give a name to them.

@3noch
3noch / scoped-bootstrap.nix
Last active November 4, 2016 12:46
Nix expression to build scoped Twitter Bootstrap CSS
# This expression builds a copy of Twitter Bootstrap CSS but with every rule embedded inside a CSS selector of
# your choice. This makes it easy to embed a Bootstrap-themed component in a site that doesn't use Bootstrap.
#
# Usage
# * Install nix from https://nixos.org/nix/ (it's a fancy package manager that won't mess up your system)
# * Save this file to `scoped-bootstrap.nix`
# * With nix stuff on your PATH, run `nix-build scoped-bootstrap.nix`
# * The result will be in `./result/` (a symlink). Copy to desired location.
# * If you don't want to keep `nix`: `rm -rf /nix`